• Resolved abazeed

    (@abazeed)


    I got this error when I switch the theme:

    PHP Fatal error: Uncaught Error: Undefined constant "USER_SWITCHING_OLDUSER_COOKIE" in /wp-content/plugins/user-switching/user-switching.php:1352
    Stack trace:
    #0 /wp-content/plugins/user-switching/user-switching.php(490): user_switching_get_olduser_cookie()
    #1 /wp-content/plugins/user-switching/user-switching.php(542): user_switching::get_old_user()
    #2 /wp-includes/class-wp-hook.php(307): user_switching->action_admin_bar_menu(Object(WP_Admin_Bar))
    #3 /wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters(NULL, Array)
    #4 /wp-includes/plugin.php(524): WP_Hook->do_action(Array)
    #5 /wp-includes/admin-bar.php(95): do_action_ref_array('admin_bar_menu', Array)
    #6 /wp-includes/class-wp-hook.php(307): wp_admin_bar_render('')
    #7 /wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters('', Array)
    #8 /wp-includes/plugin.php(476): WP_Hook->do_action(Array)
    #9 /wp-admin/admin-header.php(267): do_action('in_admin_header')
    #10 /wp-admin/admin.php(239): require_once('/Users/...')
    #11 /wp-admin/plugins.php(10): require_once('/Users/...')
    #12 {main}
      thrown in /wp-content/plugins/user-switching/user-switching.php on line 1352
    

    I’m activating the plugin on after_switch_theme hook, like this:

    function theme_init() {
        include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
        activate_plugin( 'user-switching/user-switching.php' );
    }
    add_action( 'after_switch_theme', 'theme_init' );
    

    Here’s the scenario:

    • Setup a fresh install of WordPress.
    • Delete the default themes from the themes directory.
    • Upload the custom theme to the themes directory.
    • Login and navigate to Appearance -> Themes.
    • Activate the custom theme.
    • You will get the error.

    This error disappears when you refresh the page, it appears only for one time after switching the theme.

    • This topic was modified 2 years, 2 months ago by abazeed.
    • This topic was modified 2 years, 2 months ago by abazeed.
    • This topic was modified 2 years, 2 months ago by abazeed.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘PHP fatal error when switching the theme’ is closed to new replies.