• Hello,

    I am not a programmer. But, been searching a lot how to accomplish redirecting back to referring page after successful login by UM. I have tried using um-user-login hook but not getting the code right, I guess.

    Only my posts are restricted and the login page link is in the restricted message that shows to the logged out users.

    Any help would be appreciated. Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi Ibrahim,
    I didn’t quite get what you’re trying to accomplish.
    Can you be more clear?

    Thread Starter ibrahim92

    (@ibrahim92)

    Sorry for that.

    Some of my contents, say only posts, are restricted by the UM plugin. For logged out users, the post only show a message. In that message I have provided the link to the login page (created by the UM plugin).

    After logging in, will it be possible for the user to be redirected to the original post’s link, they first ended up?

    For example, https://roadtouk.com/working-in-acute-medicine/

    Clicking “Login” takes you to the login page. And upon logging in, UM lets me choose among four things:
    1. Refresh the page (Which just refreshes the login page)
    2. Redirect to another pre-specified URL.
    3. Redirect to their profile
    4. Redirect to the admin.

    I want them to redirect to the previous page.

    Mike

    (@bigmikey00)

    You can do something like this below. This will redirect the page to the referrer after a successfull login. I am not sure how well this will work as this is before the Ultimate Member re direct.

    I would create a custom Role and do not redirect that Role anywhere on login. I beleive their is an option to redirect to referred based on the role. I am not sure though.

    <?php
    add_action( 'um_on_login_before_redirect', 'my_on_login_before_redirect', 10, 1 );
    function my_on_login_before_redirect( $user_id ) {
        // your code here
    	wp_safe_redirect( wp_get_referer() );
    }
    ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Redirect to referring page from login page after successful login’ is closed to new replies.