• Resolved John Hawkins

    (@vegasgeek)


    I’m having the weirdest issue on a site I’m working on locally. I have the user switching plugin active and I’m trying to display a message if I’ve switched to a user. I have the following code just for testing:

    if ( current_user_switched() ) {
    ray( ‘switched’ );
    } else {
    ray( ‘not switched’ );
    }

    In my browser, I’m logged in and switched to a user, but when I refresh the page, I get a “call to undefined function” error about current_user_switched().

    I went into the user-switching.php file and found the function definition… I added the following:
    if ( ! function_exists( ‘current_user_switched’ ) ) {
    ray( ‘here’);

    And the ray call fires, but I still get the undefined error.

    Any chance you can tell me what I’m doing wrong here?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author John Blackbourn

    (@johnbillion)

    WordPress Core Developer

    Are you calling the function before the User Switching plugin has loaded? If you call it immediately in another plugin then it may be too early. Try calling it within the init hook, or from within a file in your theme.

    Thread Starter John Hawkins

    (@vegasgeek)

    :facepalm:
    Yeah, that did the trick.

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.