获取用户头像,可以通过

$avatar_html = get_avatar( $email );

获取到头像的html

/**
 * Retrieve the avatar url for a user who provided a user ID or email address.
 *
 * {@see get_avatar()} doesn't return just the URL, so we have to
 * extract it here.
 *
 * @param string $email Email address.
 * @return string URL for the user's avatar, empty string otherwise.
*/
function json_get_avatar_url( $avatar_html ) {

    // Strip the avatar url from the get_avatar img tag.
    preg_match('/src=["|\'](.+)[\&|"|\']/U', $avatar_html, $matches);

    if ( isset( $matches[1] ) && ! empty( $matches[1] ) ) {
        return esc_url_raw( $matches[1] );
    }

    return '';
}

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-13
  • 2021-08-17
  • 2022-12-23
  • 2021-06-11
  • 2021-07-30
  • 2021-08-24
猜你喜欢
  • 2021-12-23
  • 2022-12-23
  • 2022-01-10
  • 2022-02-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案