• 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 2 replies - 16 through 17 (of 17 total)
  • Plugin Author John Blackbourn

    (@johnbillion)

    WordPress Core Developer

    I’ve discovered that this is caused by the fact that “WordPress SuperSonic with CloudFlare” serves every non-admin page as if it’s being viewed by a non-logged-in user. It also enforces this behaviour on wp-login.php (with an exclusion for when you’re logging out).

    The problem is due to the wpss_determine_current_user() function which assumes the only action you can do on the login screen is to log out.

    For now, you can add /wp-login.php* to the Do not logout on URLs option on the SuperSonic -> Options page.

    You should report this problem to the SuperSonic plugin author and point them to this thread.

    Strange, but what I did worked for me, I didn’t change anything else.

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