Not Taken

Redirect to MM_Member_Decision Page after Login

This is different from the similar topic "When Access Denied Redirect to Requested Page after Login".



Imagine an event registration page where bundles are tickets. We want to sell tickets to non-members and we want to offer lower prices to members. We don't content restrict the entire page. Instead we use MM_Member_Decision to show purchase links for members and non-members separately. We also prompt members who aren't logged in to log in for member pricing.



Because the entire page isn't content-protected, existing redirect-on-login functionality is never called.



I propose letting the login page take a single url parameter that we could pass to it. For instance, if someone isn't logged in, we would say, Log in for member pricing. And this would cause the login page to send the user back to the MM_Member_Decision page after they've logged in.



Under current logic, someone who follows a login link from a MM_Member_Decision page goes from there to the home page, probably never to return to the MM_Member_Decision page.



My workaround is to create a "script page" that is entirely content-restricted. It contains only



I send users there instead of to the login page. This triggers the redirect-on-login behavior. When the page loads, my user is sent back to the MM_Member_Decision page and can now see protected content.



You have exactly the same use case in your support forums here except I think you've implemented it in a more sophisticated php kind-of way. I can start typing my request, click "sign in", log in in the popup, and then I'm sent back here and the page ajaxy-recognizes me now.
Doug,

You could potentially implement this yourself using WordPress' login_redirect hook (https://codex.wordpress.org/Plugin_API/Filter_Reference/login_redirect). This is what we use internally to do the login redirect. You would just want to make the priority of your login redirect higher then ours so it gets executed first. Our priority is 10.

Thank you for your input! Even though MemberMouse will not be implementing this suggestion, your feature request provides valuable insight into the needs of our community and helps shape future plugin decisions.

Hi,

I did use the filter and I have an ajax error popup?


$redirect_to ='/myaccount'; 

$request = home_url().'/login/';

function admin_default_page( $redirect_to, $request, $user ) {

    return $redirect_to;

}

add_filter( 'login_redirect', 'myaccount', 15, 10 );


Thanks

you can use a redirection on the page too, it works.

function page_template_redirect() {
  if( is_page( 'home' ) || is_page('home-2') || is_page('home-1')) {
    wp_redirect( home_url( 'index.php/myaccount/' ) );
    exit();
  }
}
add_action( 'template_redirect', __NAMESPACE__ .'\\page_template_redirect' );

 


Login or Signup to post a comment