-
-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch back fails when Wordpress is in subdirectory and using custom login page #14
Comments
Thanks for the report. I thought I had an answer for this, but I don't think I do. I'll look into it some more. |
Thanks for looking in to it! Since I needed to fix this for my current project I went and added a filter so that it's possible to change the url depending on the switching action. I also created a pull request with these changes, if you think it's the right way to fix this issue. |
@reekris see my answer here for a solution that does not involve changing the plugin code.
|
I have the same issue with a subdirectory install and a custom url for the login page (using WPS Hide Login). When I disable WPS Hide Login, I can switch back to my session without issue, even the site is using a subdirectory installation. |
Had the same issue and was able to fix it using a variation of @alpipego's fix. Here's my setup:
Dropped this code into an mu-plugin: add_action('wp_die_handler', function($handler) {
parse_str($_SERVER['QUERY_STRING'], $query);
if ( $query['action'] === 'switch_to_olduser' ) {
wp_redirect(get_bloginfo('wpurl') . $_SERVER['REQUEST_URI']);
exit;
}
return $handler;
}); Since all |
I'm using Bedrock which puts Wordpress in it's own subdirectory. Part of this setup is to change the site url like the following:
define('WP_SITEURL', "http://site.com/wp");
This works fine along with the user swithing plugin. However I have also defined a custom login page by implementing the login_url filter.
So instead of the built-in login page
http://site.com/wp/wp-login.php
my login url becomeshttp://site.com/login
and shows a custom post with a login form.This combination breaks the "Switch back" functionality in this plugin. The reason seems to be that the auth cookie saved by the plugin uses
SITECOOKIEPATH
to save the cookie. Since this value is fetched from theWP_SITEURL
setting, the value becomes/wp
. So the cookie is only saved in the/wp
path, but my login page is in the root path. This means that the user switching auth cookie (prefixedwordpress_user_sw_
) is not available in the login page and the user switch fails with a "Could not switch off." message.Changing all instances of
SITECOOKIEPATH
in your plugin toCOOKIEPATH
fixes the problem sinceCOOKIEPATH
is fetched from the home_url setting. But I guess there is some reason for the auth cookie to be saved inSITECOOKIEPATH
while the old_user cookie is saved inCOOKIEPATH
?Another solution would be to add a filter in you plugin so that it was possible to override the url used for switching from
wp_login_url()
to something else. if you think that sounds like a good idea I'd be happy to send a pull request.Or maybe this could be solved in some other way?
The text was updated successfully, but these errors were encountered: