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
if ( !function_exists( 'update_user_caches' ) ) { require_once ABSPATH . WPINC . '/user.php'; } // User object to be cached $user = null; // NOTICE! Understand what this does before running. $result = update_user_caches($user);
Defined (1)
The function is defined in the following location(s).
- /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');
- }