wpseek.com
A WordPress-centric search engine for devs and theme authors



update_user_caches › WordPress Function

Since3.0.0
Deprecatedn/a
update_user_caches ( $user )
Parameters:
  • (object|WP_User) $user User object or database row to be cached
    Required: Yes
Returns:
  • (void|false) Void on success, false on failure.
Defined at:
Codex:

Updates 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_nicename, $user->ID, 'userslugs' );

	if ( ! empty( $user->user_email ) ) {
		wp_cache_add( $user->user_email, $user->ID, 'useremail' );
	}
}