Referrer to Login to Registration Page Redirect Persist

Is there a way to have the redirect set for the login page using this wp_login_url(get_permalink($event->get_id())) persist to the registration page if someone doesn't have an account, and return them to the originally referrer as they wait for the password. The redirect is dropped. I could just bloat and drop a second button for registration, but I'd like to do it this way.

Preferred Login Sequence
original page -> login -> oops need to register -> original page -> wait for password on original page -> login -> original page

  • mtpultz

    Hi Patrick

    I've been trying to steer away from the amount of buttons that are available. Currently the custom template only shows one button - either the Yes or No button, never the Maybe. If they aren't logged in they get redirected. Once logged in they can toggle between the Yes and No buttons, which I hide using CSS.

    If I can't get the login button to show initially to anonymous users, then I show the Yes or No buttons on login I think I'll have to keep trying to figure out how to pass the redirect_to value to the registration page from the login page.

    I can see the login button for wp is in a closure and on init it immediately associates with the RSVP buttons, so aside from altering the actually plugin I can't see how to invoke the button to show separately. Is there a way to grab eab-api.js and drop it in the theme folder and have it be used instead? Then I can just alter the closure to do what I'd like.

    Do you have any suggestions for getting the redirect_to querystring to persist from the login page to the registration page? Been trying to use get_query_var( "redirect_to" ) and using an add_filter method, but it doesn't work.

  • mtpultz

    Hi Patrick,

    I ended up not going with the wp login or trying to override the eab_api.js file. I figured out a solution to maintain the redirect_to url to the login to the registration and after registration back to the login. In case anyone else wants the solution I've dropped it below.

    Cheers

    function custom_register_url( $registration_url ) {
        $redirect_to = $_GET["redirect_to"];
        $eab_msg = $_GET["eab"];
    
        if( $redirect_to != "" && $eab_msg != ""  ) {
            // change query name values to prevent default behaviour (redirect_to to uct_redirect)
            $registration_url = sprintf( '<a href="%s&%s&%s">%s</a>', esc_url( wp_registration_url() ), "uct_redirect=" . urlencode($redirect_to), "uct_eab=" . urlencode($eab_msg), __( 'Register' ) );
        }
    
        return $registration_url;
    }
    add_filter( 'register', 'custom_register_url' );
    
    function custom_registration_redirect($registration_redirect) {
        $redirect_to = $_GET["uct_redirect"];
        $eab_msg = $_GET["uct_eab"];
    
        if( $redirect_to != "" && $eab_msg != ""  ) {
            // change query names back to original values (uct_redirect to redirect_to)
            $registration_redirect = wp_login_url( $redirect_to ) . '&eab=' . $eab_msg;
        }
    
        return $registration_redirect;
    }
    add_filter( 'registration_redirect', 'custom_registration_redirect' );

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.