WordPress 判断邮箱是否设置了头像

WordPress 判断邮箱是否设置了头像,做一下记录,下面有代码出处。

function validate_gravatar($email) {
    // Craft a potential url and test its headers
    $hash = md5(strtolower(trim($email)));
    $uri = \'http://www.gravatar.com/avatar/\' . $hash . \'?d=404\';
    $headers = @get_headers($uri);
    if (!preg_match(\"|200|\", $headers[0])) {
        $has_valid_avatar = FALSE;
    } else {
        $has_valid_avatar = TRUE;
    }
    return $has_valid_avatar;
}

代码出处:https://stackoverflow.com/questions/32755354/check-if-a-user-has-a-gravatar-wordpress

    © 版权声明
    THE END
    喜欢就支持一下吧
    点赞0 分享
    评论 抢沙发

    请登录后发表评论

      暂无评论内容