Hi @zholub,
I have a setup like your (a separate woocommerce for selling) ad so I had the same need.
I’ve solved with CSS, the data are still present on the page but hidden from view:
#learn-press-profile-nav .learn-press-tabs .orders,
#learn-press-profile-nav .learn-press-tabs .settings,
#learn-press-profile-nav .learn-press-tabs .dashboard
{
display: none!important;
visibility: hidden!important;
}
Then for making sure that user cannot access the related web pages, I’ve created some redirect rules
function redirect_courses() {
if ( is_user_logged_in() ) {
$current_user = wp_get_current_user();
wp_redirect("/profile/" . $current_user->user_login . "/courses/purchased/" );
exit;
}
else {
wp_redirect("/wp-login.php?redirect_to=%2Fcourses%2F");
exit;
}
}
function redirect_courses_init(){
if ($_SERVER['REQUEST_URI'] == "/courses/") redirect_courses();
if (preg_match('"\\/courses\\/\\?"', $_SERVER['REQUEST_URI'])) redirect_courses();
if (preg_match('"\\/profile\\/settings\\/.*"', $_SERVER['REQUEST_URI'])) redirect_courses();
if (preg_match('"\\/profile\\/certificates\\/.*"', $_SERVER['REQUEST_URI'])) redirect_courses();
if (!is_user_logged_in() && preg_match('"\\/profile\\/.*"', $_SERVER['REQUEST_URI'])) redirect_courses();
if (!is_user_logged_in() && preg_match('"\\/courses\\/.*"', $_SERVER['REQUEST_URI'])) redirect_courses();
}
add_action('init', 'redirect_courses_init');
This is an example. Maybe you need to change something following you requirements but it could be a good entry point. I.e. In my production site I’ve keeped visible the password change page, because can be useful for users.
Ciao
Fabio
-
This reply was modified 8 years, 1 month ago by
fabio.grasso.
Thread Starter
zholub
(@zholub)
Hey this worked great! Thanks a lot @fabio.grasso
The redirects don’t seem to be working for me but I’m not too concerned, the CSS accomplishes everything I’m looking for.
The last step I’m trying to do is embed this Learnpress profile in the dashboard I’ve created (so that its not just it’s own page). Do you know of a shortcode (or perhaps some not so short code) that accomplishes this?
@zholub I’m glad to have helped you 😉
Regarding the redirect, have you changed some of the slug of the url? In my example I’ve set the default english slug (i.e. /courses/ , /profile/, and so on), if you have translated something you need to change the code.
The shortcode for the profile is [learn_press_profile]
Thread Starter
zholub
(@zholub)
This is great! Thanks for all the help!