有的用户在使用erphpdown插件后,想批量清理一些没有充值记录的僵尸用户,那么如何筛选出这些用户呢?
function add_custom_user_view_link($views) { global $wpdb, $current_user; if (current_user_can('edit_users')) { $custom_link_url = admin_url('users.php?cz=no'); $custom_link_text = '无充值用户'; $views['custom_user_list'] = '<a href="' . esc_url($custom_link_url) . '" class="'.((isset($_REQUEST['cz']) && $_REQUEST['cz'] == 'no')?'current':'').'">' . esc_html($custom_link_text) . '</a>'; } return $views; } add_filter('views_users', 'add_custom_user_view_link'); add_action('pre_user_query', 'search_user_meta'); function search_user_meta($user_query) { global $wpdb; $search_term = isset($_REQUEST['cz']) ? sanitize_text_field($_REQUEST['cz']) : ''; if (!empty($search_term) && $search_term == 'no') { $users_in_table_a = $wpdb->get_col("SELECT DISTINCT ice_user_id FROM $wpdb->icemoney where ice_success=1"); $users_in_table_a = array_map('intval', $users_in_table_a); // 确保ID是整数 $user_query->query_where .= " AND {$wpdb->users}.ID NOT IN (" . implode(',', $users_in_table_a) . ")"; } }
以上代码就是模板兔提供的筛选出没有充值记录的用户。
0 个评论