Title: Empty Current User ( pre_user_query )
Last modified: August 22, 2019

---

# Empty Current User ( pre_user_query )

 *  Resolved [Howdy_McGee](https://wordpress.org/support/users/howdy_mcgee/)
 * (@howdy_mcgee)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/empty-current-user-pre_user_query/)
 * In a custom plugin I’m using `pre_user_query` to check if the current user role
   and modify the query appropriately. Whenever WP Approve User plugin is enabled
   the `global $current_user` is empty and `wp_get_current_user()` errors out because
   there is no current user. This all happens in the `pre_user_query` hook which
   runs on `wp-admin/users.php`.
 * If I disable the plugin and print `global $current_user` I get a WP_User as expected.
   Somewhere in this plugin the user is being removed.
 *     ```
       add_action( 'pre_user_query', function( $query ) {
   
       	global $current_user;
   
       	printf( '<pre>%1$s</pre>', print_r( $current_user, 1 ) );
       	die();
   
       } );
       ```
   

Viewing 1 replies (of 1 total)

 *  Plugin Author [Konstantin Obenland](https://wordpress.org/support/users/obenland/)
 * (@obenland)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/empty-current-user-pre_user_query/#post-11914804)
 * I can seem to be able to reproduce that. [Looking at the callback in WP Approve User](https://plugins.trac.wordpress.org/browser/wp-approve-user/tags/6/wp-approve-user.php#L247),
   I’m also not sure how it would achieve that. It never alters or even calls anything
   related to the current user.
 * Maybe this happens in conjunction with another plugin?

Viewing 1 replies (of 1 total)

The topic ‘Empty Current User ( pre_user_query )’ is closed to new replies.

 * ![](https://ps.w.org/wp-approve-user/assets/icon-256x256.png?rev=3013178)
 * [WP Approve User](https://wordpress.org/plugins/wp-approve-user/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-approve-user/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-approve-user/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-approve-user/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-approve-user/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-approve-user/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Konstantin Obenland](https://wordpress.org/support/users/obenland/)
 * Last activity: [6 years, 9 months ago](https://wordpress.org/support/topic/empty-current-user-pre_user_query/#post-11914804)
 * Status: resolved