1 使用官方函数
<?php
global $user_ID;
echo get_comments('count=true&user_id='.$user_ID);
?>
2 使用sql查询数据库
function get_user_comments_count( $user_id ) {
global $wpdb;
$user_id = (int) $user_id;
$sql = "SELECT COUNT(*) FROM {$wpdb->comments} WHERE user_id='$user_id' AND comment_approved = 1";
$coo = $wpdb->get_var( $sql );
return ( $coo ) ? $coo-1: 0;
}
本文作者:StubbornHuang
版权声明:本文为站长原创文章,如果转载请注明原文链接!
原文标题:WordPress – 获取某个用户发表的评论数量
原文链接:https://www.stubbornhuang.com/1362/
发布于:2021年05月26日 15:06:33
修改于:2023年06月26日 21:34:40
当前分类随机文章推荐
- WordPress - 在编辑文章发布时弹出是否发布提醒框 阅读3481次,点赞0次
- WordPress - 当用户登录失败时在登录界面显示自定义信息 阅读2047次,点赞0次
- WordPress - 修改WP Editor.md markdown编辑器插件从剪切板粘贴图片上传的清晰度和质量 阅读1328次,点赞0次
- WordPress - wp_registration_url函数详解 阅读1195次,点赞0次
- WordPress - 插件WP Editor.md 在网站更换为https后无法正确加载 阅读4321次,点赞0次
- WordPress - 网站加载自定义字体的最佳方式 阅读169次,点赞1次
- WordPress - 防止用户在登录页面重复点击登录按钮造成重复登录 阅读1021次,点赞0次
- WordPress - 用户修改密码/邮箱时禁止向管理员/用户发送通知邮件 阅读1141次,点赞0次
- WordPress - 获取某个用户发表的评论数量 阅读2168次,点赞0次
- WordPress - 获取某个用户发表的文章数量 阅读2266次,点赞0次
全站随机文章推荐
- 资源分享 - Python3网络爬虫开发实战 崔庆才著 高清PDF下载 阅读4221次,点赞0次
- 资源分享 - Game Engine Gems 3英文高清PDF下载 阅读3010次,点赞1次
- 书籍翻译 - Fundamentals of Computer Graphics, Fourth Edition,第1章 Introduction中文翻译 阅读5807次,点赞19次
- 资源分享 - Computational Geometry - Algorithms and Applications, Third Edition 英文高清pdf下载 阅读5962次,点赞1次
- 资源分享 - Mathematics for Computer Graphics , Second Edition 英文高清PDF下载 阅读1572次,点赞0次
- TensorRT - Polygraphy工具的使用 阅读5687次,点赞0次
- 资源分享 - Game Programming Gems 2 英文高清PDF下载 阅读2293次,点赞0次
- Windows平台录音类封装:AudioRecordWindows 阅读4288次,点赞0次
- WPF - 代码动态更换按钮的背景图片 阅读3558次,点赞0次
- 资源分享 - Digital Modeling of Material Appearance 英文高清PDF下载 阅读1925次,点赞0次
评论
169