最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
WordPress禁止没有Gravatar头像的邮箱提交评论
时间:2014-08-22 编辑:简简单单 来源:一聚教程网
最近被垃圾评论弄烦了,有些目测是人工评论,但是带着广告链接,看着恶心,大部分没有Gravatar头像,于是本博决定阻止掉没有头像的访客正常提交评论,
编辑所用主题的functions.php文件,加入下面的代码:
代码如下 | 复制代码 |
/* * @author:vfhky 2013年09月11日20:23 * @param string $email 用户提交的表单中的email字段 * @return int 0:无gravatar头像; 1:有gravatar头像 **/ function vfhky_checkgravatar($email) { $email_hash = md5(strtolower(trim($email))); $check_uri = 'http://www.gravatar.com/avatar/'.$email_hash.'?d=404'; $headers = @get_headers($check_uri); if (!preg_match("|200|", $headers[0])) { return 0; } else { return 1; } } |
本博客使用了Willin Kan大神的ajax提交评论,编辑comments-ajax.php,找到下面的代码:
代码如下 | 复制代码 |
if ( get_option('require_name_email') && !$user->ID ) { 修改为: if ( get_option('require_name_email') && !$user->ID ) { |
相关文章
- HTML简单购物数量小程序代码展示 10-31
- html canvas实现弹幕功能 10-31
- HTML中空格表示的意义 10-31
- html area标签解读 10-31
- html使用表单标签实现注册页面代码展示 10-31
- 使用HTML截图并保存为本地图片的代码展示 10-31