大家早上好...
我的 WordPress 网站中有一个用户讨论论坛页面,为了发表评论,用户必须先注册。但我看到很多用户注册了,但一个月内没有发表一条评论。所以我必须手动检查评论,然后删除该特定用户。
我的问题是有什么办法可以自动删除一个月内没有发表任何评论的用户。
任何人都可以帮助我完成我的任务吗?
最佳答案
<?php
global $current_user;
$args = array('user_id' => $current_user->ID);
$usercomment = get_comments($args);
if(count($usercomment) < 1){
require_once(ABSPATH.'wp-admin/includes/user.php' );
$current_user = wp_get_current_user();
wp_delete_user( $current_user->ID );
}
else {
//
}
检查此代码,如果用户评论少于 1 ,它将删除用户。我想它会给你想法
关于php - 根据WordPress中的评论删除用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38156012/