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