Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I need a way to set the default avatar for buddypress's bp_core_fetch_avatar. Using the regular get_avatar you can just set the $default path but I can't find anyway to do it with buddypress's function. For instance, I use this function to get the full size avatar for a post author but adding default => "mysite.com/default.png" doesn't pass.

function fod_post_author_avatar() {
global $post;

if ( function_exists('bp_core_fetch_avatar') ) {
    echo apply_filters( 'bp_post_author_avatar', bp_core_fetch_avatar( array( 'item_id' => $post->post_author, 'type' => 'full', 'width' => "130px", 'height' => "130px", default => "http://mysite.com/wp-content/themes/123/images/default-avatar.png" ) ) ); 
} else if ( function_exists('get_avatar') ) {
    get_avatar();
}
}
share|improve this question

closed as off-topic by kaiser Aug 4 at 16:53

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

2 Answers 2

I need a way to set the default avatar for buddypress's bp_core_fetch_avatar.

Why?

adding default => "mysite.com/default.png" doesn't pass

There is no 'default' option in that BP function http://phpxref.ftwr.co.uk/buddypress/nav.html?bp-core/bp-core-avatars.php.source.html#l78

You can define the default avatar site-wide by using BP_AVATAR_DEFAULT

share|improve this answer

As @shanebp said:

You can define the default avatar site-wide by using BP_AVATAR_DEFAULT

For this you can define the constant(s) BP_AVATAR_DEFAULT and/or BP_AVATAR_DEFAULT_THUMB inside the bp-custom.php as described at the buddypress codex page Customizing BuddyPress Avatars, for example like this:

Code:

$upload_dir = wp_upload_dir();  
$url_default_avatar = $upload_dir['baseurl'] . '/defaults/buddypress/default-member-avatar.png';  
$url_default_avatar_thumb = $upload_dir['baseurl'] . '/defaults/buddypress/default-member-avatar-thumb.png';  
define ( 'BP_AVATAR_DEFAULT', $url_default_avatar );  
define ( 'BP_AVATAR_DEFAULT_THUMB', $url_default_avatar_thumb );


Another method of setting a default avatar has been described at this answer to a (very) similar question. For this the use of gravatar gets disabled, after that you can easily change the default (member) avatar. A plus with this method is that the default group avatar can be changed easily too - that's the reasons, otherwise it would be redundant, I'm replicating this method, because the group avatar isn't part of the answer I've referenced. That said, the use of this method would for example be like this:

Code:

// disable gravatar  
add_filter( 'bp_core_fetch_avatar_no_grav', '__return_true' );

// default member avatar  
function wpse_54037_default_avatar_avatar() {
    $upload_dir = wp_upload_dir();
    return $upload_dir['baseurl'] . '/defaults/buddypress/default-member-avatar.png';
}
add_filter( 'bp_core_default_avatar_user', 'wpse_54037_default_avatar_avatar' );

// default group avatar
function wpse_54037_default_group_avatar() {
    $upload_dir = wp_upload_dir();
    return $upload_dir['baseurl'] . '/defaults/buddypress/default-group-avatar.png';
}
add_filter( 'bp_core_default_avatar_group', 'wpse_54037_default_group_avatar' );
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.