update_user_caches() WP 3.0.0
Update all user caches
No Hooks.
Return
true/false/null. Returns false on failure.
Usage
update_user_caches( $user );
- $user(object/WP_User) (required)
- User object or database row to be cached
Changelog
Since 3.0.0 | Introduced. |
Code of update_user_caches() update user caches WP 5.6
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' );
}