• I am adding Learnpress to a user dashboard that has many other options on it in addition to learn press. So in order to avoid redundancy I would like to hide all the tabs in the user profile except for Courses and Quizzes. So hiding Dashboard, Orders, and Settings). I will use the woocommerce plugin to pull in the order data in a different location so I don’t want that to get messed up either.

    Is there a way to achieve this with some code to modification perhaps?

Viewing 4 replies - 1 through 4 (of 4 total)
  • 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 6 years, 7 months 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!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘modify Learnpress user profile’ is closed to new replies.