Redirect login page to Membership buy direct link

When logged out users tries to log in directly to the link generated by the Membership Buy shortcode eg:
[ms-membership-buy id="5" label="Buy now!"]

Where the link would be:
https://websiteURL/register/?membership_id=5

Will give the above page when logged out, clicking the "Already have a user account?" link, and logging in will redirect users to their /account page.

Any workaround to change the login re-direct to the following page when users who try to login as mentioned above, gets redirected to the following page:

  • Nithin

    Hi Jay,

    I'm checking this with the developer to see whether we could have a quick workaround for this, will get back to you once I get an update regarding this from the developer. Please do note that developers work round the clock with many critical issues, and hence have a slow response time. Either myself, or the developer will keep you posted asap. Have a nice day ahead. :slight_smile:

    Best Regards,
    Nithin

  • Ivan

    Hi Jay !

    You can try to create MU plugin ( for example, create {wordpress_folder}/wp-content/mu-plugins/wpmu_change_login_url_of_membership.php file via FTP ) with the following code

    <?php
    
    function wpmu_change_login_url_of_membership( $url, $enforce ) {
    	$referer = filter_input( INPUT_SERVER, 'HTTP_REFERER' );
    	if ( $enforce && strpos( $referer, '&do-login=1' ) ) {
    		$url = str_replace( '&do-login=1', '', $referer );
    	}
    
    	return $url;
    }
    
    add_filter( 'ms-ajax-login-redirect', 'wpmu_change_login_url_of_membership', 11, 2 );

    Let me know how it goes for you. If it won't help you - please, provide me with additional login credentials, I can look into it more.

    https://premium.wpmudev.org/contact/#i-have-a-different-question
    Please visit our private Contact page and complete the form with the following information:

    Subject: "Attn: Ivan Svyrskyi"

    In the Message box, please provide the following:

    - link back to this thread for reference
    - any other relevant urls

    - Admin login:
    Admin username
    Admin password
    Login url

    - FTP/SFTP credentials
    host
    username
    password
    (and port if required)

    Best regards,
    Ivan.

  • Ivan

    Hi Jay !

    I added some modification of the code and now it works. A final version of code looks like:

    <?php
    function wpmu_change_login_url_of_membership( $url, $enforce ) {
    	$referer = !empty( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : '';
    	if ( $enforce && strpos( $referer, '&do-login=1' ) ) {
    		$url = str_replace( '&do-login=1', '', $referer );
    	}
    
    	return $url;
    }
    
    add_filter( 'ms-ajax-login-redirect', 'wpmu_change_login_url_of_membership', 11, 2 );

    Best regards,
    Ivan.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.