Title: get_currentuserinfo
Last modified: August 31, 2016

---

# get_currentuserinfo

 *  [ivandelajara](https://wordpress.org/support/users/ivandelajara/)
 * (@ivandelajara)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/get_currentuserinfo-1/)
 * get_currentuserinfo got deprecated
 * It must to be changed to wp_get_current_user
 * [https://wordpress.org/plugins/google-analyticator/](https://wordpress.org/plugins/google-analyticator/)

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

 *  [Andis](https://wordpress.org/support/users/andydegroo/)
 * (@andydegroo)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/get_currentuserinfo-1/#post-7266974)
 * I also received the notice. get_currentuserinfo is deprecated since WordPress
   4.5 and there should be a check if wp_get_current_user exists before using it.
 * I suggest following change of ga_current_user_is function in google-analyticator.
   php @ line 1288:
 *     ```
       /**
        * Determines if a specific user fits a role
        **/
       function ga_current_user_is($roles)
       {
       	if ( !$roles ) return false;
   
       	global $current_user;
       	// Fix for deprecated get_currentuserinfo since WordPress 4.5
       	if(function_exists('wp_get_current_user')) {
       		$user = wp_get_current_user(); // wp_get_current_user returns WP_User object, so there is no need to create new WP_User instance
       		if ( !$user->ID ) {
       			return false;
       		}
       	} else {
       		get_currentuserinfo();
       		$user_id = intval( $current_user->ID );
   
       		if ( !$user_id ) {
       			return false;
       		}
       		$user = new WP_User($user_id); // $user->roles
       	}
   
       	foreach ( $roles as $role )
       		if ( in_array($role, $user->roles) ) return true;
   
       	return false;
       }
       ```
   
 * I just uploaded the change on my site and the notice goes away.
 *  [lammax](https://wordpress.org/support/users/lammax/)
 * (@lammax)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/get_currentuserinfo-1/#post-7267084)
 * Thanks! It solves for me 😉
 *  [Phil Johnston](https://wordpress.org/support/users/johnstonphilip/)
 * (@johnstonphilip)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/get_currentuserinfo-1/#post-7267086)
 * Getting the same error/notice here.
 *  [mvanboordt](https://wordpress.org/support/users/mvanboordt/)
 * (@mvanboordt)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/get_currentuserinfo-1/#post-7267089)
 * Getting the same error. Is there going to be an update soon?
    I would rather 
   not edit core files.
 * M.
 *  [Edi](https://wordpress.org/support/users/psychosopher/)
 * (@psychosopher)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/get_currentuserinfo-1/#post-7267092)
 * It’s now a week since the update to WordPress 4.5 and no reaction… Seems that
   the plugin is no longer maintained.
 * [@andydegroo](https://wordpress.org/support/users/andydegroo/) Have you added
   some code?
 * My code reads like this:
 *     ```
       /**
        * Determines if a specific user fits a role
        **/
       function ga_current_user_is($roles)
       {
       	if ( !$roles ) return false;
   
       	global $current_user;
       	get_currentuserinfo();
       	$user_id = intval( $current_user->ID );
   
       	if ( !$user_id ) {
       		return false;
       	}
       	$user = new WP_User($user_id); // $user->roles
   
       	foreach ( $roles as $role )
       		if ( in_array($role, $user->roles) ) return true;
   
       	return false;
       }
       ```
   
 * All I had to do is change get_currentuserinfo() to wp_get_current_user().
 *  [Andis](https://wordpress.org/support/users/andydegroo/)
 * (@andydegroo)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/get_currentuserinfo-1/#post-7267105)
 * [@mvanboordt](https://wordpress.org/support/users/mvanboordt/) google-analyticator.
   php is not a core file. It is part of Google Analyticator plugin.
 * [@edi](https://wordpress.org/support/users/edi/) Goetschel
    I guess Noah has 
   better things to do with his time and this plugin doesn’t bring in referrals 
   to his main business – SumoMe. That would be a good reason for not spending time
   on this plugin.
 * I’ve added the fix in a way that doesn’t break in older WordPress versions. However,
   that is not necessary, because [wp_get_current_user function was added in WordPress 2.0.3](https://developer.wordpress.org/reference/functions/wp_get_current_user/).
 * Some parts of the original plugin code are not needed, because wp_get_current_user
   creates complete WP_User object with roles. So the function code for WP >= 2.0.3
   would be:
 *     ```
       /**
        * Determines if a specific user fits a role
        **/
       function ga_current_user_is($roles)
       {
       	if ( !$roles ) return false;
   
       	$user = wp_get_current_user();
       	if ( !$user->ID ) {
       		return false;
       	}
   
       	foreach ( $roles as $role )
       		if ( in_array($role, $user->roles) ) return true;
   
       	return false;
       }
       ```
   
 *  [mvanboordt](https://wordpress.org/support/users/mvanboordt/)
 * (@mvanboordt)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/get_currentuserinfo-1/#post-7267106)
 * [@andydegroo](https://wordpress.org/support/users/andydegroo/) I see what you
   mean but I ment the core files of the plugin.
    The principle is the same. Change
   the code and loose the changes after an update.
 *  [Edi](https://wordpress.org/support/users/psychosopher/)
 * (@psychosopher)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/get_currentuserinfo-1/#post-7267107)
 * [@andydegroo](https://wordpress.org/support/users/andydegroo/) Thank you for 
   the explanation.
 * And I can understand that there are better things to do than adopt changes in
   the core of WordPress that can break every few month a plugin or a theme.

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

The topic ‘get_currentuserinfo’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/google-analyticator_fefefe.svg)
 * [Analyticator](https://wordpress.org/plugins/google-analyticator/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/google-analyticator/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/google-analyticator/)
 * [Active Topics](https://wordpress.org/support/plugin/google-analyticator/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/google-analyticator/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/google-analyticator/reviews/)

 * 8 replies
 * 6 participants
 * Last reply from: [Edi](https://wordpress.org/support/users/psychosopher/)
 * Last activity: [10 years, 1 month ago](https://wordpress.org/support/topic/get_currentuserinfo-1/#post-7267107)
 * Status: not resolved