• Resolved danielfrank

    (@danielfrank)


    Hello

    I like using Ultimate Member, for sure. But one thing that really grinds my gears is the way it handles redirection after this and that, and how you’re unable to specify different settings for each function.

    It would be nice if I could just specify on each and every single registration and login form, exactly what should happen when logging in or registering.

    It is not sufficient for me to have an overall setting for this, as some pages suits different purposes for registration or login, and the user has to be somewhere – or maybe the page should just update.

    For example, on https://koldfronten.dk/tip I require users to either register or login to see the content. In order for the user to be redirected back to the same page, to see the unlocked content, I had to tamper with overall redirection settings in the role and the registration form.

    On every login form I have, I can actually specify what should happen after login. But the same doesn’t apply for the registration form. Here I only have two options: Redirect to profile page or redirect to specific URL. I want to decide that on the login form.

    How can I achieve this?

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter danielfrank

    (@danielfrank)

    Would it be possible to get help with this?

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @danielfrank

    You can use UM action and filter hooks to extend the functionality. You can try the following code snippets to redirect users back to the page where they register or log in. This will be applied to all Login and Register forms.

    add_filter("um_login_redirect_url","um_012522_login_redirect_to_url");
    function um_012522_login_redirect_to_url( $redirect_url ){
    
        return get_the_permalink();
    }
    
    add_action("um_registration_after_auto_login","um_012522_register_redirect");
    function um_012522_register_redirect(){
        exit( wp_safe_redirect( urldecode( get_the_permalink() ) ) );
    }

    You can add the code to your theme/child-theme’s functions.php file or use the Code Snippet plugin to run the code.

    Regards,

    • This reply was modified 2 years, 10 months ago by Champ Camba.
    • This reply was modified 2 years, 10 months ago by Champ Camba.
    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @danielfrank

    Please try this updated code. The above has an issue:

    add_action("um_on_login_before_redirect","um_012522_custom_redirect");
    add_action("um_registration_after_auto_login","um_012522_custom_redirect");
    function um_012522_custom_redirect(){
        exit( wp_safe_redirect( urldecode( get_the_permalink() ) ) );
    }

    Regards,

    Thread Starter danielfrank

    (@danielfrank)

    Hey @champsupertramp

    This really saved my day.

    It seems to work. I’ve deleted the user, you created. Could you try creating a new one?

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @danielfrank

    Are you still experiencing any issues?

    Regards,

    Thread Starter danielfrank

    (@danielfrank)

    Hello @champsupertramp

    No, this is just what I was looking for. Thank you very much!

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Thanks for letting us know.

    Regards,

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Redirect to specific URL after registration based on form’ is closed to new replies.