update_user_caches

Update all user caches.

Description

(bool|null) update_user_caches( (object|WP_User) $user ); 

Returns (bool|null)

Returns false on failure.

Parameters (1)

0. $user (object|WP_User)
User object to be cached

Usage

  1. if ( !function_exists( 'update_user_caches' ) ) { 
  2. require_once ABSPATH . WPINC . '/user.php'; 
  3.  
  4. // User object to be cached 
  5. $user = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = update_user_caches($user); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/user.php  
  1. function update_user_caches( $user ) { 
  2. if ( $user instanceof WP_User ) { 
  3. if ( ! $user->exists() ) { 
  4. return false; 
  5.  
  6. $user = $user->data; 
  7.  
  8. wp_cache_add($user->ID, $user, 'users'); 
  9. wp_cache_add($user->user_login, $user->ID, 'userlogins'); 
  10. wp_cache_add($user->user_email, $user->ID, 'useremail'); 
  11. wp_cache_add($user->user_nicename, $user->ID, 'userslugs');