最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

wp cron - Delete all users when they don't update profile_fields

programmeradmin3浏览0评论
  1. I create a profile_fields named name, when users sign up for an account they will receive an email containing the nickname.
  2. When the user logs in, there will be a page to enter profile_fields (name), if profile_fields = nickname (from email), they will be redirected to the main edit page.

(1,2 I did it).

I want users who can't update profile_fields (name) for a day, to be permanently deleted. Is there any way to make this work? please, i have searched many places but to no avail I found a code and corrected it but I don't know if it's wrong???

function my_clearOldUsers() {
    global $wpdb;
    $query = $wpdb->prepare("SELECT ID FROM $wpdb->users WHERE datediff(now(), user_registered) > 1");
    if ($oldUsers = $wpdb->get_results($query, ARRAY_N)) {
        foreach ($oldUsers as $user_id) {
            $nickname = $user->user_login
            $xacminh = get_user_meta( $user_id[0], 'name', true );
            if($xacminh != $nickname) {
            wp_delete_user($user_id[0]); 
            } 
        }
    }
}
add_action('my_dailyClearOut', 'my_clearOldUsers');  ```
发布评论

评论列表(0)

  1. 暂无评论