Skip to content

Instantly share code, notes, and snippets.

@chriszarate
Last active December 12, 2015 01:58
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save chriszarate/4694791 to your computer and use it in GitHub Desktop.
BuddyPress 1.6 custom site avatars.
<?php
/*
BuddyPress 1.6 custom site avatars.
Add to (or create) /wp-content/plugins/bp-custom.php.
Or place in theme's functions.php.
*/
/*
Use a specific user's avatar for a site.
Replace SITEID with the id of the site (find via Network Admin > Sites).
Replace USERID (x3) with the id of a user whose avatar you want to use (find via Network Admin > Users).
*/
add_filter('bp_get_blog_avatar_SITEID', 'my_avatar_user_USERID');
function my_avatar_user_USERID () {
echo bp_core_fetch_avatar (
array(
'item_id' => USERID,
'type' => 'thumb',
'alt' => 'SOME ALT TEXT',
'width' => 40,
'height' => 40,
'class' => 'avatar'
)
);
}
/*
You can also just return the HTML of any ole image. HACK!
*/
add_filter('bp_get_blog_avatar_SITEID', 'my_avatar_SITEID');
function my_avatar_SITEID () {
echo '<img src="http://mysite.com/path/to/avatar.jpg" alt="SOME ALT TEXT" class="avatar" width="40" height="40" />';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment