Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Is it possible to get only the avatar-url ?


yu
Participant

@gerbilo

add new function in wp-core-avatars.php ->

function bp_core_get_avatar_url( $user, $version = 1, $width = null, $height = null, $no_tag = false ) {
global $bp, $current_blog;

if ( !is_int($version) )
$version = (int) $version;

if ( CORE_AVATAR_V2_W == false && CORE_AVATAR_V2_H == false )
$version = 1;

if ( !$width )
$width = constant('CORE_AVATAR_V' . $version . '_W');

if ( !$height )
$height = constant('CORE_AVATAR_V' . $version . '_H');

$avatar_file = get_usermeta( $user, "bp_core_avatar_v$version" );
$url = $bp['root_domain'] . '/' . $avatar_file;

if ( strlen($avatar_file) ) {
if ( $no_tag )
return $url;
else
return $url;
} else {
$ud = get_userdata($user);
$grav_option = get_site_option('user-avatar-default');

if ( $grav_option == '' ) {
$default_grav = 'wavatar';
} else if ( $grav_option == 'mystery' ) {
$default_grav = site_url('wp-content/mu-plugins/bp-core/images/mystery-man.jpg');
} else {
$default_grav = $grav_option;
}

$gravatar = 'https://secure.gravatar.com/avatar/' . md5( $ud->user_email ) . '?d=' . $default_grav . '&s=';
if ( $no_tag )
return $gravatar . constant('CORE_AVATAR_V' . $version . '_W');
else
return $gravatar . constant('CORE_AVATAR_V' . $version . '_W');
}
}

and use bp_core_get_avatar_url(user_id_here,1)

Skip to toolbar