Membership Plugin

WordPress Membership Plugin

  • Home
  • Documentation
  • Addons
  • Support
    • Quick Setup
    • Documentation
    • Premium Addon Support
    • Paid Support
    • Support Forum
    • Support Forum Search
    • Forum Login
    • Forum Registration
  • Contact

[Resolved] Back to page after login

Simple Membership Plugin › Forums › Simple Membership Plugin › Back to page after login

  • This topic has 8 replies, 4 voices, and was last updated 6 years, 9 months ago by mbrsolution.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • January 1, 2018 at 3:18 am #12842
    Rin Ng
    Participant

    Hi,

    Is there a way to redirect the user back to the very same page after they login? I’ve added the login form on the sidebar so that the user can login on every page on the website and would love that the plugin can redirect the user back to the very same page they are at when they login.

    Thanks,
    Rin

    January 1, 2018 at 11:45 pm #12843
    mbrsolution
    Moderator

    Hi, please install the following plugin. Let me know if this helps you.

    Thank you

    January 3, 2018 at 6:30 pm #12865
    Rin Ng
    Participant

    Hi mbrsolution,

    I’ve installed the plugin. Selected the checkbox but it doesn’t do anything. I’m using the shortcode [swpm_login_form] , read the online documentation below and it writes there is a query “swpm_redirect_to” parameter which is tagged to the form.

    https://simple-membership-plugin.com/configure-login-redirection-members/

    Is it possible to edit the login form so that it includes the parameter for every single page or sidebar that uses the shortcode [swpm_login_form]?

    Thanks again.

    Rin

    January 3, 2018 at 10:51 pm #12868
    mbrsolution
    Moderator

    Hi, the plugin/addon does work because I have tested this myself. Can you carry out the following test. Let me know how you go.

    Thank you

    January 7, 2018 at 6:57 am #12888
    Rin Ng
    Participant

    Hi mbrsolution,

    I managed to get the redirection to work by editing the login form adding a hidden input field

    <input type="hidden" id="swpm_redirect_to" name="swpm_redirect_to" value="<?php echo (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; ?>"/>

    This will redirect the user back to the very same page where they login, good for websites that has a login panel on every page.

    Thanks for the help.

    January 7, 2018 at 8:59 pm #12892
    mbrsolution
    Moderator

    Thank you for sharing your solution. I will report this to the developers so they can investigate further your code.

    Kind regards.

    January 8, 2018 at 3:11 am #12906
    admin
    Keymaster

    Thats cool. You should actually use the following filter of the plugin to add that hidden input field to the login form. That way the code won’t get lost after a plugin upgrade.

    
    swpm_before_login_form_submit_button
    

    The following documentation has explanation:
    https://simple-membership-plugin.com/simple-membership-filter-hook-reference/

    November 27, 2019 at 12:31 am #19328
    akkatips
    Participant

    I know this thread is quite old now, however I am attempting to place this code in the functions.php file of my theme but having no luck.

    
    add_filter('swpm_before_login_form_submit_button', 'login_form_addition');?>
    function login_form_addition($output) {
        //Add any extra text message or input fields to the login form output.
        $output .= '<input type="hidden" id="swpm_redirect_to" name="swpm_redirect_to" value="<?php echo (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; ?>"/>';
        return $output; 
    }
    

    However it seems like the <?php is causing an error. Any suggestions for this?

    November 27, 2019 at 8:03 pm #19333
    mbrsolution
    Moderator

    @akkatips, have you tried the following addon?

    https://wordpress.org/plugins/simple-membership-after-login-redirection/

    There is a new feature that allows the member to be redirected back to the page they logged in from.

    Regards

  • Author
    Posts
Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.
Log In

Please read this message before using our plugin.

Search

Featured Addons and Extensions

  • Membership Form Builder Addon
  • Member Directory Listing Addon
  • WooCommerce Payment Integration
  • Member Data Exporter Addon

Documentation

  • Documentation Index Page

Copyright © 2026 | Simple Membership Plugin | Privacy Policy