您可以这样做(此代码尚未测试)。
function schedule_sql_command($user_login, $user) {
// 12 hours in seconds.
$from_now = 12 * 60 * 60;
// schedule a call to a custom hook passing in the user\'s ID
wp_schedule_single_event(time() + $from_now, \'run_sql_command\', array( $user->ID) );
}
// this is the custom hook that takes the user_id as a param
function run_sql_command($user_id) {
global $wpdb;
$wpdb->query("Your query here using $user_id");
}
// Hook when user logs in
add_action( \'wp_login\', \'schedule_sql_command\') ;