update_user_caches() WordPress Function

The update_user_caches() function is used to update the user caches. This function is called when a user is updated.

update_user_caches( object|WP_User $user ) #

Updates all user caches.


Parameters

$user

(object|WP_User)(Required)User object or database row to be cached


Top ↑

Return

(void|false) Void on success, false on failure.


Top ↑

Source

File: wp-includes/user.php

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' );
}


Top ↑

Changelog

Changelog
VersionDescription
3.0.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More