• Resolved korynorthrop

    (@korynorthrop)


    I know there are other support tickets pertaining to redirecting new users after registering for an account, but none of the solutions offered worked for me. I am trying to change the redirect URL programmatically. I have tried the following hooks and they do not work even after switching to the Twentytwentytwo theme and disabling other plugins (except LearnDash and ACF Pro).

    add_filter( 'user_registration_login_redirect', function( $redirect_url, $current_user ) {
        error_log( print_r( 'user_registration_login_redirect()', true ) );
        $redirect_url = 'https://newurl.com';
        return $redirect_url;
    }, 10, 2 );
    
    add_filter( 'user_registration_redirect_from_registration_page', function( $redirect_url, $current_user ) {
        error_log( print_r( 'user_registration_redirect_from_registration_page()', true ) );
        $redirect_url = 'https://anotherurl.com';
        return $redirect_url;
    }, 10, 2 );

    I don’t see any of the error_log statements get printed to my PHP log and I do not get redirected with any of those hooks. I’ve tried each one separately.

    • This topic was modified 2 years, 7 months ago by korynorthrop.
Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Support Amrit Kumar Shrestha

    (@shresthauzwal)

    Hi @korynorthrop,

    Please use the following code snippet for redirection after login.

    add_filter( 'user_registration_login_redirect', 'redirect_after_login', 10, 2 );
    function redirect_after_login($redirect_url, $user ) {
        $redirect_url = 'https://www.google.com';
        add_filter( 'allowed_redirect_hosts', 'get_ur_host', 10, 2 );
        return $redirect_url;
    }
    function get_ur_host($wpp_host, $url_host) {
        return array_merge($wpp_host, array( $url_host));
    }

    Note: For registration redirect, please use auto login user option to work properly.

    Regards!

    Thread Starter korynorthrop

    (@korynorthrop)

    Thanks for your reply @shresthauzwal. I added your code snippet, but it didn’t help. I already mentioned that I tried using the user_registration_login_redirect filter to no avail. It doesn’t even seem like that filter is firing because I have an error_log() statement in the function that is called on that filter, but nothing gets printed to my error log.

    I have the “User Approval And Login Option” setting set to “Auto approval and auto login” as well.

    What other ideas do you have?

    Plugin Support Amrit Kumar Shrestha

    (@shresthauzwal)

    Hi @korynorthrop,

    Please check this link you will get the user registration plugin file. We have included the filter in this file. We suggest you install this plugin on your site and try the previously provided code.

    I hope this helps.

    Regards!

    Thread Starter korynorthrop

    (@korynorthrop)

    I replaced the version of the User Registration plugin with the .zip version in your link, but it is still not working. The user_registration_login_redirect filter does not appear to fire whatsoever.

    Plugin Support Amrit Kumar Shrestha

    (@shresthauzwal)

    Hi @korynorthrop,

    Could you please try the following code once?

    add_filter( 'user_registration_success_params','user_registration_success_params' , 11, 4 );
    function user_registration_success_params( $success_params, $valid_form_data, $form_id, $user_id ) {
        $redirect_url = 'https://www.google.com';
        $success_params['role_based_redirect_url'] = $redirect_url;
        return $success_params;
    }

    If this also does not work for you, please provide a screenshot of where you are adding these codes and your loin page links. So we can investigate further and provide you with the appropriate solution.

    Regards!

    Thread Starter korynorthrop

    (@korynorthrop)

    @shresthauzwal I tried the user_registration_success_params filter and it worked, the new user was redirected to the new $redirect_url defined in the custom function. Is there documentation for the user_registration_success_params filter, I searched your website, but could not find anything.

    So of all of the hooks that I’ve tried, these ones successfully fired:

    user_registration_success_params
    user_registration_before_register_user_action
    user_registration_after_register_user_action

    But these ones do not fire:

    user_registration_login_redirect
    user_registration_redirect_from_registration_page
    • This reply was modified 2 years, 7 months ago by korynorthrop.
    Plugin Support Amrit Kumar Shrestha

    (@shresthauzwal)

    Hi @korynorthrop,

    Glad to know that the solution works, and also thank you for the information,

    Currently, the code we provided does not have any specific documentation because we have written this code manually for you.

    If you have a moment to spare, we would really appreciate your review of our plugin. Please click on this link https://www.ads-software.com/support/plugin/user-registration/reviews/#new-post and share your thoughts about our team and our plugin. We would love to hear from you.
    ?
    Thanks!

    Thread Starter korynorthrop

    (@korynorthrop)

    @shresthauzwal I’m curious why you had to write custom code for me when your plugin ostensibly already had filters in place to do the exact thing that I was trying to do. Is there a plan to address those other filters that aren’t firing?

    Plugin Support Amrit Kumar Shrestha

    (@shresthauzwal)

    Hi @korynorthrop,

    Thank you for your suggestion,

    These filters are already included, but somehow latest update removed them. We will be more careful about our upcoming updates. If you have a moment to spare, we would appreciate your review of our plugin. Please click on this link https://www.ads-software.com/support/plugin/user-registration/reviews/#new-post and share your thoughts about our team and our plugin. We would love to hear from you.
    ?
    Thanks!

    Thread Starter korynorthrop

    (@korynorthrop)

    It’s a bit strange to me that the filters would be removed without any mention of that in the version notes. But, also, the filters still exist in the code base they just don’t work.

    i’ve spent more than a hour trying all possible solutions you @shresthauzwal and @sanjuacharya77 have been suggesting in your support forum to no avail, to then end up in this thread and discover that:

    1. supposedly User Registration has indeed filters to send users back to the last page they have visited before logging in (or after registering)
    2. these filters have either been removed or no longer working… they surely are doing nothing in version 2.2.6
    3. you’d love us to review your plugin despite us trying to get a solution from you in the last year (at least since this thread)

    any chance of a definitive answer on how to use the filters before us committing to a plugin review?

    (i’m using WP 6.1.1, Astra theme and Elementor)

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Redirect URL hooks are not firing’ is closed to new replies.