_fill_single_user

Definition:
function _fill_single_user( &$user, &$metavalues ) {}

Unserialize user metadata, fill $user object, then cache everything.

Parameters

  • object $user: The User object.
  • array $metavalues: An array of objects provided by get_user_metavalues()
  • &$user
  • &$metavalues

Source code

function _fill_single_user( &$user, &$metavalues ) {

	global $wpdb;



	foreach ( $metavalues as $meta ) {

		$value = maybe_unserialize($meta->meta_value);

		// Keys used as object vars cannot have dashes.

		$key = str_replace('-', '', $meta->meta_key);

		$user->{$key} = $value;

	}



	$level = $wpdb->prefix . 'user_level';

	if ( isset( $user->{$level} ) )

		$user->user_level = $user->{$level};



	// For backwards compat.

	if ( isset($user->first_name) )

		$user->user_firstname = $user->first_name;

	if ( isset($user->last_name) )

		$user->user_lastname = $user->last_name;

	if ( isset($user->description) )

		$user->user_description = $user->description;



	update_user_caches($user);

}

4317

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: