John Blackbourn
Forum Replies Created
-
Forum: Plugins
In reply to: [User Switching] Can’t switch to an userThis might be related to a caching issue or a cookie issue. Can you try clearing your browser cookies and removing any cache related plugins to see if they’re causing the problem?
Forum: Plugins
In reply to: [User Switching] Compare to Login As User?That plugin started as a fork of User Switching many years ago but has since diverged. I don’t know what it does differently these days!
What problem are you seeing in Bricks?
Forum: Plugins
In reply to: [User Switching] Switching from the frontend?Yep, take a look through the FAQ for some options.
Forum: Plugins
In reply to: [User Switching] Any way to get originating user during switch-ception?That’s cool. Off the top of my head I think it only affects sites that are using HTTPS on the admin area and HTTP on the front end (hopefully zero website these days), Multisite installations which use domain mapping, or sites that use funky custom configuration for their cookies. I would say a standard single site installation is fine.
Alternatively you can use any one of the user role management plugins available that allow you to specifically deny a capability from a user. That way you don’t need to write any code for it.
Yes you can do this by denying the
view_query_monitor
capability from users who you don’t wish to have it. Here’s some example code.add_filter( 'user_has_cap', function( $allcaps, $caps, $args, $user ) {
if ( 'view_query_monitor' === $args[0] ) {
// Put your logic here:
if ( my_condition( $user ) ) {
$allcaps['view_query_monitor'] = false;
}
}
return $allcaps;
}, 9, 4 );Thanks! Yes I’ve fixed a few of these but missed this one. I’ll get an update out soon.
Yeah I get it, but to be honest this occurs quite rarely. It’s a developer error to return anything but a string from either of those filters, so it’s best to just fix the root cause. There are plenty of developer tools such as PHPStan which make it easy to detect that kind of error.
This means that another plugin on your site is using one of the
logout_redirect
orlogin_redirect
filters and returning anull
value, which is incorrect. It’s just unfortunate that User Switching gets the blame due its strict return type declaration.Can you try deactivating your other plugins one by one to try to find the culprit?
Forum: Plugins
In reply to: [User Switching] First name, Last name and E-mail not filledI’m not sure what to say about this issue to be honest. On a fresh installation of WooCommerce, the user’s name and email is filled out as expected when switching to a user and then visiting the checkout screen.
I can only think that there is a caching issue or a plugin on your site which is affecting the checkout screen.
Sorry I can’t be of any further help.
Forum: Plugins
In reply to: [User Switching] Any way to get originating user during switch-ception?Short answer: No.
Long answer: Yes, kind of. The stack of authentication tokens for switched users is stored in User Switching’s auth cookie, serialised as JSON (see the
user_switching_set_olduser_cookie()
function). Due to the way that WordPress separates “logged in” and “auth” cookies for reasons relating to sites that use HTTPS only in the admin area, the “auth” cookie might not be available during requests to the front end of your site, but it will for sure be available in the admin area.There’s no PHP function in User Switching to fetch and verify the top-most (actually the bottom-most) user from this stack. You can take a look at the
authenticate_old_user()
method and see how it reads the last item in the cookie stack and validates its value withwp_validate_auth_cookie()
.Please take a look through the info on the “More information” link below the message.
Can you provide some more information please? What do you mean by the workflow settings page? Can you provide a screenshot?
Forum: Plugins
In reply to: [User Switching] Reporting: Plugin bugged outThanks for the report. This sounds like an error in the caching mechanism on your site. There’s nothing fundamental in User Switching which could cause you to get “stuck” on another user, because the actual user authentication is handled by WordPress itself. It’s not possible for User Switching to affect other browsers, other customers, etc.
I’m not sure what to suggest, other than to try flushing the object cache and page cache on your site, and if the problem occurs again in the future you might want to try deactivating any caching plugins on your site.
Good luck!