Title: Fatal error: Missing function get_old_user()
Last modified: August 22, 2016

---

# Fatal error: Missing function get_old_user()

 *  Resolved [Michael Visser](https://wordpress.org/support/users/visser/)
 * (@visser)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/fatal-error-missing-function-get_old_user/)
 * Fatal error from PHP error log:
 * [23-Mar-2015 11:50:36 UTC] PHP Fatal error: Call to a member function get_old_user()
   on a non-object in […]\wp-content\plugins\admin-bar-user-switching\admin-bar-
   user-switching.php on line 111
 * To reproduce this:
 * 1. De-activate and delete Admin Bar User Switching
    2. Install Admin Bar User
   Switching 4.1.1 via WordPress Plugin installer 3. Activate Plugin 4. No fatal
   error on activation trigger so Admin screen loads 4. Fatal error after activation
   causes blank screen after WP Admin 5. Affects all WP Admin screens, doesn’t cause
   blank screen on Theme side but does blank our WP Admin bar.
 * Solution:
 * Manually rename admin-bar-user-switching to _admin-bar-user-switching within /
   wp-content/plugins/… via FTP or file manager.
 * [https://wordpress.org/plugins/admin-bar-user-switching/](https://wordpress.org/plugins/admin-bar-user-switching/)

Viewing 12 replies - 1 through 12 (of 12 total)

 *  [Mark Wilkinson](https://wordpress.org/support/users/wpmarkuk/)
 * (@wpmarkuk)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/fatal-error-missing-function-get_old_user/#post-5930594)
 * Can you confirm that you have the [User Switching plugin](https://wordpress.org/plugins/user-switching/)
   active when you active the Admin Bar User Switching plugin please.
 *  Thread Starter [Michael Visser](https://wordpress.org/support/users/visser/)
 * (@visser)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/fatal-error-missing-function-get_old_user/#post-5930600)
 * Hi Mark, User Switching was not installed or activated, works a treat once User
   Switching was activated. 🙂
 * Consider using class_exists or function_exists before loading resources from 
   another Plugin and an Admin notice prompt to install and activate User Switching
   if it’s not installed or activated.
 *  [Mark Wilkinson](https://wordpress.org/support/users/wpmarkuk/)
 * (@wpmarkuk)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/fatal-error-missing-function-get_old_user/#post-5930605)
 * The plugin does do exactly that:
 * [https://github.com/wpmark/admin-bar-user-switching/blob/master/admin-bar-user-switching.php#L30-L55](https://github.com/wpmark/admin-bar-user-switching/blob/master/admin-bar-user-switching.php#L30-L55)
 * Therefore not sure how it managed to bypass this!
 *  Thread Starter [Michael Visser](https://wordpress.org/support/users/visser/)
 * (@visser)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/fatal-error-missing-function-get_old_user/#post-5930607)
 * Hi Mark, I assume (and this is a wild shot) that the wp_before_admin_bar_render
   Action runs before the admin_notices Action.
 * Update: Yup, that looks like the culprit, /wp-admin/admin-header.php #203
 * do_action( ‘in_admin_header’ );
 * followed by #239 26 lines later…
 * do_action( ‘admin_notices’ );
 * Adding another class_exists within abus_adminbar_output() that returns nothing
   should resolve this.
 *  [Mark Wilkinson](https://wordpress.org/support/users/wpmarkuk/)
 * (@wpmarkuk)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/fatal-error-missing-function-get_old_user/#post-5930611)
 * What you are saying makes sense. However I have just do the following:
    1. Deactivated all plugins
    2. Activate the Admin Bar User Switching Plugin – admin notice shows and plugin
       is deactivated because User Switching is not active
    3. Activate User Switching
    4. Activated Admin Bar User Switching
    5. Deactivate User Switching – admin notices shows the error and the Admin Bar 
       User Switching plugin is deactivated.
 * Therefore what I have in the plugin seems to be working in that if the User Switching
   plugin is not active the Admin Bar add-on won’t active and if the two are activated
   and User Switching is deactivated it deactivates the Admin bar one.
 * At no point do I see a fatal error.
 *  Thread Starter [Michael Visser](https://wordpress.org/support/users/visser/)
 * (@visser)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/fatal-error-missing-function-get_old_user/#post-5930618)
 * Hi Mark, with both User Switching and Admin Bar User Switching activated I clicked
   de-activate on User Switching to see what would happen. I hit the fatal error
   and blank screen on WP Admin.
 * Adding…
 * if( ! class_exists( ‘user_switching’ ) )
    return;
 * to line #110 of admin-bar-user-switching.php and refreshing the Plugin screen
   then showed the WP Admin screen with the de-activation notice you wrote. What
   I noticed however was that the Switch to User dropdown on the WP Admin bar was
   still visible, this is because is it rendered as part of the in_admin_header 
   Action and so the Plugin is calling resources from User Switching without knowing
   that the Plugin has been de-activated and before the de-activation script you’ve
   written kicks in as part of admin_notices Action.
 * Here’s my version details:
 * WordPress 4.1.1
    User Switching 1.0.3 User Switching in Admin Bar 1.0.3
 * Logged in as an Administration User Role
 * Thanks for your time looking at this with me
 *  [Mark Wilkinson](https://wordpress.org/support/users/wpmarkuk/)
 * (@wpmarkuk)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/fatal-error-missing-function-get_old_user/#post-5930763)
 * Happy to go ahead and apply that fix but I would like to be sure of why I am 
   not seeing this and you are. Could you test this on another install please in
   the same environment making sure it a vanilla WP install with just the two required
   plugins?
 *  Thread Starter [Michael Visser](https://wordpress.org/support/users/visser/)
 * (@visser)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/fatal-error-missing-function-get_old_user/#post-5930768)
 * I’ll do this tomorrow morning on one of my development sites and confirm here
   🙂
 *  Thread Starter [Michael Visser](https://wordpress.org/support/users/visser/)
 * (@visser)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/fatal-error-missing-function-get_old_user/#post-5930828)
 * Yup, same issue. Both scenario’s no Plugins activated, default Twenty Fifteen
   Theme.
 * === Scenario 1 ===
 * Install Admin Bar User on new WordPress site without User Switching using the
   WordPress Plugins Installer.
 * Result: Fatal error on activation, can only be resolved by renaming/deleting 
   Plugin directory for Admin Bar User Switching.
 * === Scenario 2 ===
 * Install User Switching on new WordPress site and activate Plugin, then install
   and activate Admin Bar User Switching from WordPress Plugins Installer. Then 
   de-activate Admin Bar User Switching from the Plugins screen.
 * Result: Fatal error on de-activation of Admin Bar User Switching, can only be
   resolved by renaming/deleting Plugin directory for Admin Bar User Switching.
 *  [Mark Wilkinson](https://wordpress.org/support/users/wpmarkuk/)
 * (@wpmarkuk)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/fatal-error-missing-function-get_old_user/#post-5930840)
 * I have now added a check in the admin bar output function to check for user switching
   being active. This should prevent your issue. Released in 1.0.4 a few minutes
   ago!
 *  Thread Starter [Michael Visser](https://wordpress.org/support/users/visser/)
 * (@visser)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/fatal-error-missing-function-get_old_user/#post-5930841)
 * Works like magic 🙂
 *  [Mark Wilkinson](https://wordpress.org/support/users/wpmarkuk/)
 * (@wpmarkuk)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/fatal-error-missing-function-get_old_user/#post-5930842)
 * Excellent glad it works for you!

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘Fatal error: Missing function get_old_user()’ is closed to new replies.

 * ![](https://ps.w.org/admin-bar-user-switching/assets/icon-128x128.png?rev=1419846)
 * [Admin Bar User Switching](https://wordpress.org/plugins/admin-bar-user-switching/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/admin-bar-user-switching/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/admin-bar-user-switching/)
 * [Active Topics](https://wordpress.org/support/plugin/admin-bar-user-switching/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/admin-bar-user-switching/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/admin-bar-user-switching/reviews/)

## Tags

 * [fatal error](https://wordpress.org/support/topic-tag/fatal-error/)

 * 12 replies
 * 2 participants
 * Last reply from: [Mark Wilkinson](https://wordpress.org/support/users/wpmarkuk/)
 * Last activity: [11 years, 2 months ago](https://wordpress.org/support/topic/fatal-error-missing-function-get_old_user/#post-5930842)
 * Status: resolved