Hi everybody,

We are using this function in a custom plugin and works well for us.
In our website, we are showing part of information to all users that are not logged in or has a free level account configured in Paid Memberships Pro.
In our menu we are showing dinamically and conditional log in or log out button. Log in option open a modal window that contain Theme My Login shortcode hiding all options except the access form. When user access to their account, this refresh current page to show all information that are hidden to non logged in users or users with free account and user no need to search again the desired content throught our website avoiding wasting time and preventing it from getting frustrated
If user logged in is an administrator or an author, this redirect to wordpress admin dashboad.

[code]function custom_login_redirect( $url, $request, $user ){
if( $user && is_object( $user ) && is_a( $user, ‘WP_User’ ) ) {
if( $user->has_cap( ‘administrator’) or $user->has_cap( ‘author’)) {
$url = admin_url();
} else {
$url = $_SERVER[‘HTTP_REFERER’];
}
}
return $url;
}
add_filter(‘login_redirect’, ‘custom_login_redirect’, 10, 3 );[/code]

Hope this could be interesting for someone.

TML has its own referer

Referer
Check this option to send the user back to the page they were visiting before logging in.

Is this doing the same thing, and referring members back to the page they were on when logging in?

Hello, I am using Theme My Login and this code doesn’t work here – /wp-login.php?redirect_to=!!referrer!!
Every time a customer trying to log in, every time he or she didn’t get an access. There is something like a circle… log in – profile – login…
After login they can see their profile page but when they try to access only members pages they are forced to log in again and everything repeating again and again.
I know the problem is in this code /wp-login.php?redirect_to=!!referrer!! because I am using Theme My Login.
Can you tell me the right code?

Hi There,

I am working with the Redirect User on Login = to a specific page for a particular Level.
https://www.paidmembershipspro.com/redirecting-members-on-login/

To get this to work I had to disable TML Redirection because that was trumping my pmpro_redirect plugin. Now that I have the single level redirect, I’d like to redirect everyone else to the referrer page. How would I do this.

Here is my Code: I have the level two commented out, wanted it in place for the future if I needed it.

ID))
{
//check level
if(pmpro_hasMembershipLevel(9, $user->ID))
return home_url("/become-a-member/renew/");
//elseif(pmpro_hasMembershipLevel(2, $user->ID))
// return home_url("/level-two/");
else
return home_url("/membership-account/");
}
}
add_filter("login_redirect", "my_login_redirect", 10, 3);

Hi can you help me with writing this? I want to referr the person back to the referring url after check out for 1 particular level. Thanks

We can help in the member forums if you post there. Mention the comment here and that I said we would deliver the code. Be sure to include as much information about which level it is/etc.

Shooot! Sorry, did that wrong and no way to edit.
Does the /wp-login.php?redirect_to=!!referrer!! go inside regular href quotation marks?

hi Jason,

Does this “referrer” redirect work in case if we are using a pop up to login users ?
I mean if a user clicks on a article pop up opens asking him to enter login details and once user is logged in he is redirected to the article he clicked on.

Leave a Reply

For faster support related to issues on your specific site please open a ticket in our members support area.

Your email address will not be published. Required fields are marked *