Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @jennifersuess

    Please try adding this code snippets to your theme’s function file or use the Code Snippet plugin:

    add_action("um_after_login_fields", function(){
        if( isset( $_SERVER['HTTP_REFERER'] ) && !isset( $_REQUEST['redirect_to'] ) ){
            echo "<input type='hidden' name='redirect_to' value='".esc_attr( $_SERVER['HTTP_REFERER'] )."'>";
        }
    });

    The above code should redirect a user back to the previous page after successful login.

    Regards,

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @jennifersuess

    Please feel free to re-open this thread by changing the Topic Status to ‘Not Resolved’ if any other questions come up and we’d be happy to help. 🙂

    Regards,

    Thread Starter jennifersuess

    (@jennifersuess)

    Thank you for trying to help me. I tried adding the code you gave me both ways (using the Code Snippets plugin and directly editing the theme’s functions.php file). Neither worked for me — I did not see any change in behavior.

    The way I’m testing this is when I am not logged into WordPress, I paste a URL into the address bar for a post that is not accessible to non-members:

    https://xxxxx.org/Test/?p=19

    Then, I see the login form, as expected, and both before and after adding the code, the URL looks like this when I see the login form:

    https://xxxxx.org/Test/?page_id=12#038;redirect_to=https%3A%2F%2Fxxxxx.org%2FTest%2F%3Fp%3D19

    I see the “redirect_to” and the id of the post (19) at the end that I would expect it to redirect to, but again, it is doing this both with and without the code change.

    When I complete the login, it does not bring me to the page I had pasted into the address bar (https://xxxxx.org/Test/?p=19). Where it brings me depends on the setting I have in the Ultimate Member login form option for “Redirection after login”. Right now I have this set to “Default” (and I tried the other options) which brings me to my member profile.

    I tried all this using a brand new website, just for testing this, to make sure that I wasn’t getting any conflicts with other plugins, or other code changes I tried to make.

    I am new to WordPress, so maybe there is something simple I’m missing! Like does this have anything to do with my permalink settings? I have the Ultimate Member login form option for “Redirection after login” set to “Default” (and I tried the other options); is there something else missing? Any additional help would be appreciated!

    Thank you!

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @jennifersuess

    Have you tried checking the Login Options in the User Role settings?

    Please go to WP Admin > Ultimate Member > User roles > Edit the role of your test account > see “Login Options”. See “Action to be taken after login” and try the option “Refresh Active page”.

    Regards,

    Thread Starter jennifersuess

    (@jennifersuess)

    Thank you. I tried doing this and it still does not work. I made a quick (2 mins) loom video demo showing my settings and what’s happening.

    If you’re quite sure that this should work, maybe you will notice something else that I’m doing wrong.

    Thanks!

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @jennifersuess

    Could you please contact us via team@ultimatemember.com to assist you further?

    Regards,

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hey there!

    This thread has been inactive for a while so we’re going to go ahead and mark it Resolved.

    Please feel free to re-open this thread by changing the Topic Status to ‘Not Resolved’ if any other questions come up and we’d be happy to help. 🙂

    Regards,

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Redirect to previous page with Ultimate Member’ is closed to new replies.