Problem overriding M2P login link

With Membership 2 Pro enabled, go to yoursite.com/account page as a logged out user and then use "lost password" link below the login form. Go through the lost password procedure and after the password is reset you got a message saying that it's been reset and a "Login with your new password" link.

The goal is to override this link URL (not the text/label but URL) with our own defined URL.

  • Ash

    Hello Trevor

    I am afraid this is not currently possible out of the box that I have added the feature in the code for the upcoming version.

    For now, please go to /wp-content/plugins/membership-2/app/view/shortcode/class-ms-view-shortcode-login.php line no 580 and find the following code:

    $url = esc_url_raw(
    					remove_query_arg( array( 'action', 'key', 'login' ) )
    				);

    Add the following code after the above code:

    $url = apply_filters(
    					'ms_sc_login_new_login_url',
    					$url
    				);

    Save and close the file

    Now you need to write some more code:

    add_filter( 'ms_sc_login_new_login_url', function( $url ) {
        return 'YOUR CUSTOM LOGIN URL';
    } );

    Change "YOUR CUSTOM LOGIN URL" with the original url. You can use this code in your theme's functions.php if the theme is not changed. Otherwise mu-plugin is the best option. To create a mu-plugin, go to wp-content/mu-plugins folder. If there is no mu-plugins folder then, create one. Now, inside the mu-plugins folder create file with name anything.php (make sure file extension is .php). Now start with a <?php tag and then put the above code.

    About the changes in the core code, I will try to add the code in next release, but just in case if I can't, it must be added in later release.

    Hope it helps! Please feel free to ask more questions if you have any.

    Have a nice day!

    Cheers,
    Ash

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.