{"id":32673,"date":"2010-05-25T10:00:58","date_gmt":"2010-05-25T14:00:58","guid":{"rendered":"http:\/\/wpmu.org\/?p=32673"},"modified":"2013-07-01T16:30:05","modified_gmt":"2013-07-01T20:30:05","slug":"how-to-add-a-custom-default-avatar-for-buddypress-members-and-groups","status":"publish","type":"post","link":"https:\/\/wpmudev.com\/blog\/how-to-add-a-custom-default-avatar-for-buddypress-members-and-groups\/","title":{"rendered":"How to Add a Custom Default Avatar For BuddyPress Members and Groups"},"content":{"rendered":"<p>A custom default avatar is something that can greatly increase the visual appeal of your BuddyPress site.<\/p>\n<p>I don&#8217;t have to sell you on this.\u00a0When I see those ugly monster avatars littering a BuddyPress site, my first instinct is to leave the page.<\/p>\n<p>Aesthetics play a huge role in your site&#8217;s ability to keep users around long enough to find out what you&#8217;re about. The default avatar is also another opportunity to keep your brand consistent throughout the site.<\/p>\n<h2>Banish the Mystery Man, Ugly Monsters, and Trippy Patterns<\/h2>\n<p><a rel=\"lightbox[32673]\" class=\"blog-thumbnail\" href=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2010\/05\/customavatar.jpg\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-32679\" title=\"customavatar\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2010\/05\/customavatar.jpg\" alt=\"Post image\" aria-hidden=\"true\" width=\"640\" height=\"188\" \/><\/a><\/p>\n<h2>How to Change the Default Avatar for Members in BuddyPress<\/h2>\n<p>Just add this simple little snippet to the <i>functions.php<\/i> file in your child theme:<\/p>\n<pre>function myavatar_add_default_avatar( $url )\r\n{\r\nreturn get_stylesheet_directory_uri() .'\/_inc\/images\/pokerchip.png';\r\n}\r\nadd_filter( 'bp_core_mysteryman_src', 'myavatar_add_default_avatar' );<\/pre>\n<p>I put this together based on Travel-Junkie&#8217;s <a href=\"http:\/\/buddypress.org\/community\/groups\/how-to-and-troubleshooting\/forum\/topic\/group-avatars-how-to-change-the-default\/\" rel=\"noopener\" target=\"_blank\">suggestion<\/a> on the BuddyPress forums.<\/p>\n<h2>How to Change the Default Avatar for Groups in BuddyPress<\/h2>\n<p>Add this to the <i>functions.php<\/i> file in your child-theme:<\/p>\n<pre>function my_default_get_group_avatar($avatar) {\r\nglobal $bp, $groups_template;\r\n\r\nif( strpos($avatar,'group-avatars') ) {\r\nreturn $avatar;\r\n}\r\nelse {\r\n$custom_avatar = get_stylesheet_directory_uri() .'\/_inc\/images\/pokerchip.png';\r\n\r\nif($bp-&gt;current_action == \"\")\r\nreturn '&lt;img class=\"avatar\" src=\"'.$custom_avatar.'\" alt=\"' . attribute_escape( $groups_template-&gt;group-&gt;name ) . '\" width=\"'.BP_AVATAR_THUMB_WIDTH.'\" height=\"'.BP_AVATAR_THUMB_HEIGHT.'\" \/&gt;';\r\nelse\r\nreturn '&lt;img class=\"avatar\" src=\"'.$custom_avatar.'\" alt=\"' . attribute_escape( $groups_template-&gt;group-&gt;name ) . '\" width=\"'.BP_AVATAR_FULL_WIDTH.'\" height=\"'.BP_AVATAR_FULL_HEIGHT.'\" \/&gt;';\r\n}\r\n}\r\nadd_filter( 'bp_get_group_avatar', 'my_default_get_group_avatar');<\/pre>\n<p>Credit for this code goes to BP forum moderator <a href=\"http:\/\/buddypress.org\/community\/groups\/how-to-and-troubleshooting\/forum\/topic\/group-default-avatar\/?topic_page=1&amp;num=15\" rel=\"noopener\" target=\"_blank\">r-a-y<\/a>. The only thing you&#8217;ll need to change here is the name of the image you&#8217;re using for the default avatar and it will automatically display.<\/p>\n<p>Simple, isn&#8217;t it? Some site admins might think that leaving the monsters\/mystery men would motivate your users to upload an avatar of their own. You underestimate the casual internet user. Keep your site&#8217;s design unified by changing your default avatars today.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A custom default avatar is something that can greatly increase the visual appeal of your BuddyPress site. I don&#8217;t have to sell you on this.\u00a0When I see those ugly monster avatars littering a BuddyPress site, my first instinct is to leave the page. Aesthetics play a huge role in your site&#8217;s ability to keep users [&hellip;]<\/p>\n","protected":false},"author":4099,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"blog_reading_time":"","wds_primary_category":0,"wds_primary_tutorials_categories":0,"footnotes":""},"categories":[1,235,263],"tags":[80],"tutorials_categories":[],"class_list":["post-32673","post","type-post","status-publish","format-standard","hentry","category-news-community","category-misc","category-tutorials","tag-avatars"],"_links":{"self":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/32673","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/users\/4099"}],"replies":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/comments?post=32673"}],"version-history":[{"count":5,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/32673\/revisions"}],"predecessor-version":[{"id":181724,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/32673\/revisions\/181724"}],"wp:attachment":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/media?parent=32673"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/categories?post=32673"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/tags?post=32673"},{"taxonomy":"tutorials_categories","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/tutorials_categories?post=32673"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}