Support » Plugin: WP User Manager - User Profile Builder & Membership » Redirect member back to URL after they log in

  • Resolved joeinc


    I using WP User Manager and I have some content that is for members only, when a logged out user tries to access it they are redirected to the login page.

    So for example a non-logged in user goes to “” and is redirected to “” and they login they are then redirected to the default logged in homepage instead of the previous page. I have the below code using a filter from the WP User Manager plugin, currently when I log in after clicking on gated content with the below code I get

    Has anyone been any to redirect back to the previous URL once a user logs in? It seems to work with the standard WordPress login form but no the custom WP User Manager one

    Anyone have any suggestions?

    add_action( 'wp', 'sc_capture_before_login_page_url' );
    function sc_capture_before_login_page_url(){
        if( !is_user_logged_in() ):
        $_SESSION['referer_url'] = get_the_permalink();
    // ** REDIRECT **/
    add_filter( 'wpum_redirect_after_login', 'my_wpum_redirect_after_login', 10, 2 );
    function my_wpum_redirect_after_login( $redirect, $user ) {
        $url = $_SESSION['referer_url'];
            if ( ! $url ) {
                return $redirect;
            // If whole of the URL then return $url
        return home_url( $url );
  • You must be logged in to reply to this topic.