A WordPress-centric search engine for devs and theme authors



update_user_caches ›

Since3.0.0
Deprecatedn/a
update_user_caches ( $user )
Parameters:
  • (WP_User) $user User object to be cached
    Required: Yes
Returns:
  • (bool|null) Returns false on failure.
Defined at:
Codex:

Update all user caches



Source

function update_user_caches( $user ) {
	if ( $user instanceof WP_User ) {
		if ( ! $user->exists() ) {
			return false;
		}

		$user = $user->data;
	}

	wp_cache_add( $user->ID, $user, 'users' );
	wp_cache_add( $user->user_login, $user->ID, 'userlogins' );
	wp_cache_add( $user->user_email, $user->ID, 'useremail' );
	wp_cache_add( $user->user_nicename, $user->ID, 'userslugs' );
}