• Resolved pavelkoko

    (@pavelkoko)


    When a user tries to access page that is restricted to one of memberships, and user is not logged in, LLMS shows that the user should be member of membership.

    The user is a member of the membership, he is not logged in!

    This is very misleading. Users writes admins – it makes user and admin nervious.

    Is there a setting that will redirect user to the login page? Or show notice that the user is not logged in?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @pavelkoko

    You can make use of the code here to redirect a restricted membership to the login page: https://gist.github.com/thomasplevy/7ab5f2e74906c55201260791d890d6de

    Just make sure this line is changed to your URL: https://prnt.sc/vyu0zw

    You can add this code using the “Code Snippets” plugin.

    Let me know if this helps.

    Thank you ??

    Thread Starter pavelkoko

    (@pavelkoko)

    Not exactly what i needed: i needed to redirect students only when they are not logged in, but if they are show standart llms message.

    I was able to change code for my task. Thank you, Toyin!

    There is my code:

    
    /**
     * Redirect restrictions to a custom URL
     * @param    array     $results  array or result info
     * @return   void
     */
    function my_llms_page_restrictions( $results ) {
    
    	// url to redirect to when user does nt have access
    	$redirect_url = '/lk';
    
    	if ( $results['is_restricted'] and !is_user_logged_in() ) {
    
    			wp_redirect( $redirect_url );
    			exit;
    		
    	}
    
    	return $results;
    }
    add_filter( 'llms_page_restricted', 'my_llms_page_restrictions' );
    
    • This reply was modified 4 years, 3 months ago by pavelkoko.
    • This reply was modified 4 years, 3 months ago by pavelkoko.

    You’re welcome @pavelkoko

    Take care!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to redirect to login page?’ is closed to new replies.