php - 根据WordPress中的评论删除用户

标签 php mysql wordpress

大家早上好...

我的 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/

相关文章:

php - 如何获得最低质量的YouTube视频?

php - 在 Laravel Blade View 中从 JSON 数据创建菜单

mysql - 如何重命名 MySQL 中的主键约束?

php - 从数据库生成实体

php - Woocommerce,获取当前产品 ID

javascript - 具有随机值的古腾堡 block 属性未保存

php - 如何在 prestashop 中添加自定义产品 "Sort by"字段?

python - SQLAlchemy - 简单的选择语句

javascript - Lightbox Overlay 不会在 Chrome 或 Edge 中向下滚动

php - 拉维尔 5 : check if user belongs to the moderators list before allowing him to edit