An alternative way to do what I wanted :
Save the time when the action has been ran and check the difference with actual time :
function my_save_statistiques( $user_id ) {
$user_id = get_current_user_id();
$current_time = time();
if (empty($current_time)) {
update_usermeta( $user_id, 'last_analytics', $current_time );
}
$last_analytics = get_user_meta( $user_id, 'last_analytics', true );
$diff = $current_time - $last_analytics;
$one_day = 86400;
if ($diff > $one_day) {
$visites_totales = [myscript]
update_usermeta( $user_id, 'last_analytics', $current_time );
update_usermeta( $user_id, 'visites_totales', $visites_totales );
}
}
add_action( 'wp_head', 'my_save_statistiques' );
So, the script will run for a logged user if the time between the last “run” and now is more than 24h, knowing that my website is only accessible to a logged user