3
我想爲WORDPRESS製作一個腳本,該腳本可以按角色(例如「訂閱者」)刪除超過20天的用戶。我搜索了一個插件,但我無法找到任何。按角色刪除舊用戶
我發現這個腳本按角色刪除用戶,但我想刪除具有相同角色的超過20天的用戶。
<?php
define('WP_USE_THEMES', false);
require('./wp-load.php');
$role = "subscriber"; // The role to kill
$reassign = 1; // The user that all posts will fall back to, other wise they will be deleted
$this_role = "[[:<:]]$role[[:>:]]";
$query = $wpdb->prepare("SELEC T user_id FROM $wpdb->usermeta WHERE meta_key = '{$wpdb->prefix}capabilities' AND meta_value RLIKE %s", $this_role);
if ($users_of_this_role = $wpdb->get_results($query, ARRAY_N))
foreach ($users_of_this_role as $user_id)
wp_delete_user($user_id[0], $reassign);
不能在查詢'$ query'的日期/時間字段,以及補充的嗎?我不知道wordpress的數據庫結構,但我相信它應該工作 – KyleMassacre