Replace the default group avatar

//*****************************************************
//*****************************************************
//********** CHANGE THE DEFAULT GROUP AVATAR **********
//*****************************************************
//*****************************************************
add_filter( 'bp_get_group_avatar', 'my_default_get_group_avatar');
function my_default_get_group_avatar($avatar)
{
  global $bp, $groups_template;

  if( strpos($avatar,'group-avatars') || (!is_object($groups_template)))
  {
    return $avatar;
  }
  else
  {
    $custom_avatar = get_stylesheet_directory_uri() . '/images/my_image_name.png';

    if($bp->current_action == "")
      return '<img class="avatar" src="'.$custom_avatar.'" alt="' . esc_attr( $groups_template->group->name ) . '" width="'.BP_AVATAR_THUMB_WIDTH.'" height="'.BP_AVATAR_THUMB_HEIGHT.'" />';
    else
      return '<img class="avatar" src="'.$custom_avatar.'" alt="' . esc_attr( $groups_template->group->name ) . '" width="'.BP_AVATAR_FULL_WIDTH.'" height="'.BP_AVATAR_FULL_HEIGHT.'" />';
  }
}
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *