clean_user_cache() – Cleans all user caches.

You appear to be a bot. Output may be restricted

Description

Cleans all user caches.

Usage

clean_user_cache( $user );

Parameters

$user
( WP_User|int ) required – User object or ID to be cleaned from the cache

Returns

void

Source

File name: wordpress/wp-includes/user.php


Lines:

1 to 29 of 29
function clean_user_cache( $user ) {
  if ( is_numeric( $user ) ) {
    $user = new WP_User( $user );
  }

  if ( ! $user->exists() ) {
    return;
  }

  wp_cache_delete( $user->ID, 'users' );
  wp_cache_delete( $user->user_login, 'userlogins' );
  wp_cache_delete( $user->user_nicename, 'userslugs' );

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

  
/**
 * Fires immediately after the given user's cache is cleaned.
 *
 * @since 4.4.0
 *
 * @param int     $user_id User ID.
 * @param WP_User $user    User object.
 */
  do_action( 'clean_user_cache', $user->ID, $user );
}
 

 View on GitHub View on Trac