WorkLizard

Insert custom buddypress group avatars

You can insert custom Buddypress group avatars if no avatars have been uploaded by the user to the group. This detail can help sculpture your Buddypress site towards a more nuanced design.

Alter the path to your image in $custom_avatar and you’re set to go.

To enhance on this, you could also add custom default user profile and group cover images.

bp-custom.php

function default_custom_get_group_avatar($avatar)
	{
	global $bp, $groups_template;
	if (strpos($avatar, 'group-avatars'))
		{
		return $avatar;
		}
	  else
		{
		$custom_avatar = get_stylesheet_directory_uri() . '/images/image.png'; //fill in the path to your image
		if ($bp->current_action == "") return '<img class="avatar" alt="' . attribute_escape($groups_template->group->name) . '" src="' . $custom_avatar . '" width="' . BP_AVATAR_FULL_WIDTH . '" height="' . BP_AVATAR_FULL_HEIGHT . '" />';
		  else return '<img class="avatar" alt="' . attribute_escape($groups_template->group->name) . '" src="' . $custom_avatar . '" width="' . BP_AVATAR_FULL_WIDTH . '" height="' . BP_AVATAR_FULL_HEIGHT . '"/>';
		}
	}

add_filter('bp_get_group_avatar', 'default_custom_get_group_avatar');

Share this post

Exit mobile version