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

  • Patrick
    • Support Monkey

    Hi there @mtpultz

    I hope you are having a great day!

    You are referring to the login/register sequence in the Events+ plugin, correct? If so, I'm afraid I'm not sure I understand your request here.

    When a site visitor clicks the "I'm Attending" button and chooses to login via WordPress, they are presented with a popup login/register form and can do so without leaving the page.

  • mtpultz
    • Site Builder, Child of Zeus

    Hi Patrick, to cut down on the amount of buttons I've been using the anonymous user redirect functionality of the RSVP buttons.

    Am I able to invoke the call to show the Login to Wordpress button wherever I want in a custom template I've made? and is it easy to customize the modal registration form's styles?

  • Patrick
    • Support Monkey

    Hi again @mtpultz

    I hope you are well today!

    I'm not quite sure how you could invoke the function to output the form. But you will find the code that does it in events-and-bookings/js/eab-api.js at line 62:
    function create_wordpress_login_popup ($action, post_id)

  • mtpultz
    • Site Builder, Child of Zeus

    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
    • Site Builder, Child of Zeus

    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.


    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.