Override Sidebar Login Redirect After Registration

I am currently using Sidebar Login Plugin which I'm very happy with. It redirects people to whatever page they were on, which is perfect, except in one instance.

When a new member registers and logs in, he is taken to the registration form he has just completed.

Is there any way that a new member can be redirected after registration to a specific page - i.e. over ride the instructions from Sidebar Login?

I am using Simple Membership and have installed the SM Redirect Addon, but the system ignores it. Sidebar Login takes precedence.

I'm not hopeful that this can be accomplished but had to ask.
Thank you.

  • James Morris
    • WordPress Enthusiast

    Hello Mary,

    I hope you are well today. Thank you for your question.

    What you are wanting to accomplish can actually be done quite simply in page templates. The Simple Membership plugin has an add-on for form shortcodes. First, you will want to install that. Once installed, you can grab your form shortcode and place it in a custom page template.

    The easiest way to make a custom page template is to download the file page.php and save it as a new file.

    For example: If your page has the title "Simple Membership Registration", you would name the file page-simple-membership-registration.php as WordPress picks up on the file name based off the URL slug.

    Inside that file, you would need to add some code similar to this at the beginning:

    if ( is_user_logged_in() ) :
    	wp_redirect( site_url() );

    This tells WordPress to check to see if the user is logged in. If they are, redirect to the homepage. If they are not, display the page.

    Now, inside the page template, where the WordPress loop is, you will need to replace the WordPress loop with a do_shortcode statement like so:

    echo do_shortcode("[swpm_registration_form]");

    This tells WordPress to render the Simple Memberships shortcode for the registration form.

    I've included a sample file for your inspection. This sample file is based off of the Twenty Sixteen theme and is not suitable for use on your site. However, it is a good starting point to see how all this pulls together.

    I hope this helps. Let me know if you have any further questions. I'll be happy to help! :slight_smile:

    Best regards,

    James Morris

  • Mary
    • Wisp of the WP Loop

    Thank you so much James!

    I tried another solution of adding the following to my child theme functions.php. (It was easier and seems to be working well.)

    add_action('swpm_front_end_registration_complete', 'sam_after_registration_redirection');
    function sam_after_registration_redirection()
    $url = 'https://mywebsite.com/after-registration/';
    wp_redirect($url); }

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.