• Resolved flexi2202

    (@flexi2202)


    Hello
    I come back to you again … because I absolutely have to find a way to redirect a user to the previous page after login. I tried this code but without success

    
    
    add_action( 'wp', 'get_before_login_url' );
    function get_before_login_url(){
        if( !is_user_logged_in() ):
        $_SESSION['referer_url'] = get_the_permalink();
        endif;
    }
    /*@ After successful login redirect */
    if( !function_exists('after_login_redirect') ):
        function after_login_redirect() {
     
        $redirect_url = home_url('/');
        if ( isset($_SESSION['referer_url']) ):
            $redirect_url = $_SESSION['referer_url'];
            unset( $_SESSION['referer_url'] );
        endif;
     
        return $redirect_url;
        exit;
       }
       add_filter('login_redirect', 'after_login_redirect');
    endif;

    `

    • This topic was modified 3 years, 1 month ago by flexi2202.
Viewing 2 replies - 1 through 2 (of 2 total)
  • this is what i use on one of my page, in this case /events/board-meeting/:
    Homeowners [wpmem_logged_in]are welcome to <a href="https://zoom.or.whatever/">attend virtually</a>.[/wpmem_logged_in][wpmem_logged_out]<a href="/owners/login/?redirect_to=/events/board-meeting/"> please log in</a> to view virtual meeting link.[/wpmem_logged_out]

    u simply put the url of the current page into the login/?redirect_to value…sorry, i have not found an automagic method…

    Thread Starter flexi2202

    (@flexi2202)

    Thanks for the code
    it’s perfect I’m going to look at this … for now I’m looking with a modal

    • This reply was modified 3 years, 1 month ago by flexi2202.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘redirection after connection’ is closed to new replies.