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

functions - Deleting guests profile users after 1.5 hours

programmeradmin4浏览0评论

I need to automatically delete the users that are subscribed through a wpforms after 90 minutes of being created.

Users created this way are marked as "invitados" on the profile.

I found this answer on a previous question:

    if(!wp_next_scheduled('my_dailyClearOut')) {

        wp_schedule_event(time(), 'daily', 'my_dailyClearOut');  }

        function my_clearOldUsers() {
        global $wpdb;
        $query = $wpdb->prepare("DELETE FROM $wpdb->users WHERE datediff(now(), user_registered) > 30");
        if ($oldUsers = $wpdb->get_results($query, ARRAY_N)) {
        foreach ($oldUsers as $user_id) {
            wp_delete_user($user_id[0]);
        }
     }
  }
        add_action('my_dailyClearOut', 'my_clearOldUsers');

However, this deletes all types of users including administrator. I only want to delete the type "invitados", I also would like this script to run each 30 minutes and delete all "invitados" that were created 90 minutes ago.

Can anyone help?

发布评论

评论列表(0)

  1. 暂无评论