Setting default Avatars for your Groups and Member pages
Most people are not big fans of the default Gravatars BuddyPress uses. That’s why you might want to use your own default images for new Members and Groups. This snippet was inspired by a post by Sarah Gooding on WPMU.org (which snippet did not work for me) and some help from Jeff Sayre through Twitter. The
Put the following code in functions.php or bp-custom.php:
/* Default Avatars */ function bn_new_mysteryman () { return get_stylesheet_directory_uri() . '/_inc/images/no_photo.jpg'; } add_filter('bp_core_mysteryman_src','bn_new_mysteryman',2,7 ); function my_default_get_group_avatar($avatar) { global $bp, $groups_template; if( strpos($avatar,'group-avatars') ) { return $avatar; } else { $custom_avatar = get_stylesheet_directory_uri() .'/_inc/images/no_photo.jpg'; if($bp->current_action == "") return ''; else return ''; } } add_filter( 'bp_get_group_avatar', 'my_default_get_group_avatar');
Put the default images you want to use in your themes folder _inc/images/ directory and you’re done. If you need a default image, you can use this one for groups:
And this one for Members:
Looking for quality BuddyPress hosting? We will guide you through all the available hosting options and help you find the best webhost for your next BuddyPress project!
Hello,
can u share the psd of the too picture?
nice tricks!
Sure.. I’ll upload them and update the post
I have tried these out on a number of sites and the change to the dafault members avatar is fine, but I have had problams as others have with the default group avatar. You can see my recent link as to what the problem is…and our plugin to solve the problem
Hi Daniel,
Cool you’ve made a plugin for it! Also like the fact that you can upload an image and do not have to use functions.php or bp-custom.php. Well done
nice hack
any idea why site.com/members/me/groups/ may display custom avatars at 50px X 50px and default once at 150px X 150px ?
Hi Bowe,
Thanks for this code… I tried it but for default user avatar, it didn’t work! What could the problem be?
thanks for the great snippet, worked like a charm. It makes the pages load much faster too as the theme is not searching for external avatars via gravatar
then i put that code in the fuction.php i get this error > Parse error: syntax error, unexpected T_STRING in…….