This topic has 1 reply, 2 voices, and was last updated 9 years by Abe.

  • Author
  • #40895
     bhavya
    Participant

    Hi,

    I have a function in functions.php that redirects users to the login page if they’re trying to access any other page without being logged in which works fine.

    COPY CODE
    if (!function_exists('restrict_access_if_logged_out')){
    	function restrict_access_if_logged_out(){
    		$current_url=$_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
    		if (!is_user_logged_in() && !($current_url === $loginpage)){
    			wp_redirect($loginpage);
    			exit;
    		}
    	}
    }
    add_action( 'wp', 'restrict_access_if_logged_out', 3 );

    The problem is that I need to redirect them to the url they were trying to go to after they successfully log in.

    Is there a way to do this?

    PS : I tried passing $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] to the ‘kleo_modal_login_redirect’
    filter in the login form action. But since the requested url is already changed to the $loginpage url by this time, it just redirects to the home page after log in.

    #41260
     Abe
    Keymaster

    Hi, I will look over this and try to add an option in the admin panel to enable redirecting to the last page on login.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

Viewing 2 posts - 1 through 2 (of 2 total)

The forum ‘KLEO’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?