Action
uncanny-automator
automator_cache_maybe_clear_user_cache
Fires after a user's cache might be cleared, allowing for custom actions or modifications to the caching process.
add_action( 'automator_cache_maybe_clear_user_cache', $callback, 10, 1 );
Description
Fires after user cache transients are cleared, allowing developers to perform custom actions. Use this hook to manually clear other related user-specific caches or trigger additional user data updates when the core user cache is refreshed.
Usage
add_action( 'automator_cache_maybe_clear_user_cache', 'your_function_name', 10, 1 );
Examples
add_action( 'automator_cache_maybe_clear_user_cache', function() {
// This example function clears a specific user-related transient cache
// when the 'automator_cache_maybe_clear_user_cache' action is fired.
// In a real-world scenario, you might want to clear more specific caches
// or perform other related cleanup tasks.
$transient_to_clear = 'my_custom_user_data_cache';
// Delete the transient. WordPress provides delete_transient() for this.
delete_transient( $transient_to_clear );
// Optionally, you could log this action or trigger other processes.
// error_log( "Cleared user cache transient: {$transient_to_clear}" );
}, 10, 0 ); // Priority 10, accepts 0 arguments
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
src/core/lib/helpers/class-automator-cache-handler.php:276
public function maybe_clear_user_cache() {
$transient_key = 'automator_transient_users';
$this->remove( $transient_key );
do_action( 'automator_cache_maybe_clear_user_cache' );
}