How to Replace BuddyPress Avatar with a Custom One

So i received a question from a customer over at ProfilePress if it was possible for avatars or profile pictures uploaded by users of his website via ProfilePress powered front-end registration and edit profile forms to automatically replace that of BuddyPress.

You know, BuddyPress has its own mechanism for uploading and managing users avatar. Having his website users editing their avatars in two places didn’t quite go down well with him.

So i dug into BuddyPress core and found these two filters: bp_core_fetch_avatar and bp_core_fetch_avatar_url. The former is called when bp_core_fetch_avatar() function is used by BuddyPress to return HTML element of users avatar and the latter when the function returns raw URL of users avatar.

So i wrote the code snippets below utilising the above filters to automatically overrides / replace BuddyPress avatar with that of ProfilePress.

You can easily adapt the code snippet to fit your need.

Be sure to let me know in the comments if you found this code snippet useful.

Don't miss my updates.
Subscribe to Receive Programming, Web development, Git and WordPress Tutorials & all things tech.