• Resolved Marcelo Pedra

    (@kent-brockman)


    Hello John. I’m having such a strange issue: when I click to switch to another user I get this message: “Could not switch users.”

    As your plugin is using this string for 3 different error situations, I played with the text string to find out what cycle is where it is failing, and it happens here:

    # Check authentication:
    if ( ! current_user_can( 'switch_to_user', $user_id ) ) {
       wp_die( esc_html__( 'Could not switch users.', 'user-switching' ) );
    }

    Obviously, I’m administrator or super-admin when in Multisite, but it looks like the plugin cannot determine that I have enough capabilities to switch_to_user.

    It is happenning no matter if the destination user of the switch is another admin, a subscriber, an editor, etc.

    I tested it in several versions and scenarios and see that this randomly happen on sites with WP 4.4/4.5/4.6 and in WP 4.6 Multisite.
    No PHP errors are being logged, though.

    On WP 4.6 Multisite with PHP 5.6.24 it failed to switch users.
    On WP 4.6 with PHP 5.6.24 without SSL it randomly failed (worked in some sites and don’t work in others).
    On WP 4.6 with PHP 5.6.24 with SSL the plugin works ok.
    On WP 4.6 with PHP 5.5.38 the plugin works ok.
    On WP 4.6 with PHP 5.4.45 the plugin works ok.
    On WP 4.4 with PHP 5.4.45 the plugin works ok.
    On WP 4.0 with PHP 5.4.45 the plugin works ok.
    On WP 3.8 with PHP 5.4.45 the plugin works ok.

    Please share any ideas or fixes or further tests I can take to discover the source of failure.

    Best regards

    https://www.ads-software.com/plugins/user-switching/

Viewing 15 replies - 1 through 15 (of 17 total)
  • Hi, I have the same error message come up on my screen, when I click ‘switch to’ link. Please help.

    Plugin Author John Blackbourn

    (@johnbillion)

    WordPress Core Developer

    Thanks for the message.

    * Are you using a domain mapping plugin on multisite?
    * Do you have a mixture of SSL and non-SSL in use on any of the sites? (eg. SSL only in the admin area?)
    * Do you have any plugins that are common among the sites where you see failures?
    * Can you try deactivating your other plugins one by one to see if the problem disappears?

    Thread Starter Marcelo Pedra

    (@kent-brockman)

    Hello John.
    * Yes, I’m using domain mapping. I further tested it, and the switch problem seems to happen when the network is configured to use subdomains. In networks with parked domains is working ok.
    * No, SSL is activated on standalone sites. No Multisites with SSL by now.
    * Yes, I have a lot of plugins in common to the sites with failures AND those same plugins are common to the sites and multisites where it don’t failed.
    * It’s difficult to deactivate plugins in these sites as they have traffic and are in production. I’ll try to find a while in the night.

    Look, something similar have happened to me last week with Loco Translate plugin, and I asked him now how was it fixed so you can have any clues:
    https://www.ads-software.com/support/topic/v20-throw-error-500-under-multisite?replies=12

    I’ll keep you posted about any news.

    Thread Starter Marcelo Pedra

    (@kent-brockman)

    @yps33:
    Hi! Can you share what version of WP are you running and if possible what version of PHP? (You can see PHP version in your desktop by installing the plugin “WP Memory Usage”).

    I know it’s hard to determine when this issue started as normally you wouldn’t be switching users too often, but anyway: can you tell if this happenned BEFORE you upgrade to WP 4.6? or have you noticed it right after the upgrade?

    Hi, I have not upgraded to WP4.6, it’s the version just before. PHP: 5.6.10

    I am using WP 4.5.3.

    Hi all,

    I found the cause of my problem, quite by accident, and am sharing in case it helps anyone else facing the same issue.

    I have “google analytics” plugin installed on my wordpress and under “backend settings” under “permissions” there is an option to “enable switch view functionality”. Mine was set to off, which caused the error in the “user switching” plugin. After I set this option to “on”, user switching works.

    Hope this helps someone else!

    Thread Starter Marcelo Pedra

    (@kent-brockman)

    @yps33:
    From what you said, I guess you talk about this plugin: “Google Analytics Dashboard para WP” by Alin Marcu. Is not it?

    I also use it, but in my case nothing changed after implementing your solution. Screen capture:
    https://drive.google.com/file/d/0B4ZIdz9VEIQGbkFHeVYtbndjSDA/view?usp=drivesdk

    Any ideas?

    Yes, that’s the one I use. Sorry it didn’t work for you, I have no other ideas…

    Plugin Author John Blackbourn

    (@johnbillion)

    WordPress Core Developer

    yps33:
    That option in the plugin doesn’t affect User Switching at all. Did you alter something else in the meantime?

    marcelo:
    Let me know when you’ve been able to try deactivating some of your other plugins. I suspect one of them is incorrectly interfering with user permissions.

    Thread Starter Marcelo Pedra

    (@kent-brockman)

    @john:
    I tracked down the issue to be cause by free plugin “WordPress SuperSonic with CloudFlare” which is a connector to enable and manage caching of assets on Cloudflare. No matter if the cloudflare API is setup or not, or if Cloudflare is enabled or in development mode (transparent proxy), the User Switching plugin will work only when that plugin is inactive.
    So, it is probably enforcing a hard caching of user sessions.

    All in all, I have a Multisite environment where Cloudflare is not in use, and User Switching is also unable to work. So, there must been another plugin acting on user sessions that could be interfering. May this assumption be correct?

    Thread Starter Marcelo Pedra

    (@kent-brockman)

    This is the list of active plugins in the Cloudflare based site, where the issue is solved by deactivating “WordPress SuperSonic with CloudFlare”:

    Autoptimize
    BackWPup
    BAW Force Plugin Updates
    Broken Link Checker
    Comet Cache
    CSS & JavaScript Toolbox
    Google Adsense Dashboard
    Google Analytics Dashboard para WP
    Heartbeat Control
    InfiniteWP – Client
    iThemes Security
    Jetpack por WordPress.com
    Jetpack Post Views
    Media Search Enhanced
    Q2W3 Fixed Widget
    Quick Featured Images
    Relevanssi
    Simple History
    TinyMCE Advanced
    Toolbar Publish Button
    User Last Login
    Video Thumbnails
    WCP OpenWeather
    Wordpress SuperSonic with CloudFlare
    WP-Memory-Usage
    WP-Optimize
    WP-UserOnline
    Yoast SEO

    Thread Starter Marcelo Pedra

    (@kent-brockman)

    And these are the active plugins in the Multisite install where your plugin don’t work. I cannot clone nor freely deactivate plugins here because it’s a huge site in production. I can deactivate one or two but late in the night, but not everything.

    3D tag cloud
    Activate Update Services
    Advanced Custom Fields
    Auto Post Thumbnail
    Broken Link Checker
    Cache Images
    Cool Tag Cloud
    Custom Post Type UI
    Google Analytics Dashboard para WP
    Google Doc Embedder
    Heartbeat Control
    Imsanity
    InfiniteWP – Client
    Instagram Feed
    iThemes Security
    Jetpack por WordPress.com
    Media Search Enhanced
    New Blog Defaults (CETS)
    Quick Featured Images
    Recently Registered
    Redirection
    Remember Me Checked
    Reorder My Sites
    Simple History
    Templatera
    TinyMCE Advanced
    UpdraftPlus – Backup/Restore
    User Last Login
    User Switching
    W3 Total Cache
    WordPress MU Domain Mapping
    WP-Memory-Usage
    WP-Optimize
    WP-UserOnline
    WPBakery Visual Composer (Artbees Modified Version)
    WPMU Plugin Stats
    WPMU Theme Usage Info
    Yoast SEO

    Any suspects you can choose?

    Plugin Author John Blackbourn

    (@johnbillion)

    WordPress Core Developer

    Thanks Marcelo!

    I’ll take a look at “WordPress SuperSonic with CloudFlare” and see if I can find out where it’s tripping things up.

    Thread Starter Marcelo Pedra

    (@kent-brockman)

    Thank you John! Anyway, take into account that the Multisite is not using Clooudflare. So there must be some other plugin session related that is interfering with yours.

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Can't switch users on some websites’ is closed to new replies.