I think that’s possible already, give it a try?
Tried it. But sadly after logging in, the user is automatically directly to ‘wp-admin’.
Not sure what is causing this to happen. Any ideas?
works for me. maybe another plugin conflict?
I’ve checked all my activated plugins, and none seem to interfere with your plugin. I’m using WP 3.1, and I want Subscribers to be redirected to their last visited Page/Post. However, they aren’t logging in via your Widget, but through the WP-Login.php page. I’m guessing that:
1. The WP core could be overriding your plugin’s login redirection, or
2. The %LASTURL% has to be redirected 2 pages back rather than 1 (meaning that it’s to back pass the “WP-Login.php” page first, and then the last visited page).
Could the latter be the case?
the plugin redirects to the same page the user logged into (i guess you can call it refresh). this overrides the wp default redirect, which is not a refresh.
If people log in through the normal login with that redirect, it’ll refresh the login but then wp will redirect you to the dashboard.
Looks like I guessed right about the latter case. If that’s the case, where can I modify the %LASTURL% redirection to back the URL twice, instead of once?
LoginWithAjax::getLogoutRedirect(), modify the str_replace
Hi Marcus,
I just realised that it isn’t the ‘getLogoutRedirect()’ function, but rather the ‘getLoginRedirect()’. I don’t have any problems with the former function though.
In login-with-ajax/login-with-ajax.php, I found the ‘getLoginRedirect()’ function:
function getLoginRedirect($user){
$data = $this->data;
if($data['login_redirect'] != ''){
$redirect = $data["login_redirect"];
}
if( strtolower(get_class($user)) == "wp_user" ){
$user_role = array_shift($user->roles); //Checking for role-based redirects
if( isset($data["role_login"][$user_role]) ){
$redirect = $data["role_login"][$user_role];
}
}
//Do string replacements
$redirect = str_replace('%USERNAME%', $user->user_login, $redirect);
$redirect = str_replace("%LASTURL%", $_SERVER['HTTP_REFERER'], $redirect);
return $redirect;
}
How do I amend the ‘str_replace’, so that it goes back twice to the last visited page? Please advise. Thank you.