Restrict Avatars to Friends in BuddyPress

Home / Tutorials / Plugins / Restrict Avatars to Friends in BuddyPress

Restrict Avatars to Friends in BuddyPress

In this quick tutorial, I will demonstrate how to hide BuddyPress Profile Photos to only friends.

Create the file bp-custom.php in your WordPress plugins folder then add the following to file.

The simple filter above bp_core_fetch_avatar will be used to alter the image prior to being displayed. Within the function we will first check if the friends component has been enabled. Then we use friends_check_friendship to check if the logged in user is friends with the current user. We use the $params[‘object’] to determine if this is a group or user avatar. If  the users are not friends then we will replace the avatar_url variable with a different image url.

Leave your comments below. Happy Coding.

Recommended Posts
Contact Us

We're not around right now. But you can send us an email and we'll get back to you, asap.

Not readable? Change text. captcha txt

Start typing and press Enter to search