Advertisements

get_currentuserinfo

Definition:
function get_currentuserinfo() {}

Populate global variables with information about the currently logged in user.
Will set the current user, if the current user is not set. The current user will be set to the logged in person. If no user is logged in, then it will set the current user to 0, which is invalid and won’t have any permissions.

Return values

returns:False on XMLRPC Request and invalid auth cookie. Null when current user set

Source code

function get_currentuserinfo() {

	global $current_user;



	if ( defined('XMLRPC_REQUEST') && XMLRPC_REQUEST )

		return false;



	if ( ! empty($current_user) )

		return;



	if ( ! $user = wp_validate_auth_cookie() ) {

		 if ( is_blog_admin() || is_network_admin() || empty($_COOKIE[LOGGED_IN_COOKIE]) || !$user = wp_validate_auth_cookie($_COOKIE[LOGGED_IN_COOKIE], 'logged_in') ) {

		 	wp_set_current_user(0);

		 	return false;

		 }

	}



	wp_set_current_user($user);

}

1340

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: