Are you saying that you want to use BP avatars on WP author pages?
If so, find the call to the avatar on the authors template.
And replace it with something like this:
<img class="" src="<?php
$authorUserID = get_the_author_meta('ID'); // get the user id of the post author
echo bp_core_fetch_avatar (
array( 'item_id' => $authorUserID, // output user id of post author
'type' => 'full',
'html' => FALSE // FALSE = return url, TRUE (default) = return url wrapped with html and css classes
)
);
As it was almost impossible for me to achieve what I wanted (due to my low knowledge), I switched to an easier alternative.
Provide random avatars for users who did not upload an avatar, any of the codes below will work, but reloading the page reloads a different avatar. Would you know how to make the avatar save and not change when reloading the page? Greetings mate
define ( 'BP_AVATAR_DEFAULT', 'uploads/Avatar-'.rand( 1 , 13 ).'.jpg' );
$pics = array ('Avatar-1.jpg','Avatar-2.jpg','Avatar-3.jpg','Avatar-4.jpg');
$picid = $pics[array_rand($pics,1)];
define( 'BP_AVATAR_DEFAULT', BP_PLUGIN_URL . 'uploads/'. $picid);
define( 'BP_AVATAR_DEFAULT_THUMB', BP_PLUGIN_URL . 'uploads/'. $picid );
$picid = mt_rand(1, 15); //100 = No. of images
define( 'BP_AVATAR_DEFAULT', BP_PLUGIN_URL . 'uploads/'.$picid.'.jpg' );
Perhaps this plugin would be useful to you:
BP Local Avatars
I’ll give up and use the typical mystery man, because I couldn’t adapt your plugin to load a local random avatar with the following code:
'Avatar-folder/Avatar-name'.rand( 1 , 15 ).'.jpg'
I’m sorry I bothered you @shanebp, thank you for your great work towards the bp community.
There are several filter hooks you could try.
Look towards the bottom of function bp_core_fetch_avatar
in this file:
wp-content\plugins\buddypress\bp-core\bp-core-avatars.php
For example, I would try this one first:
function gabriel_random_avatar( $default_grav, $params ) {
// $default_grav is an url
// replace it with the full url to one of your preferred avatars
return $default_grav;
}
add_filter('bp_core_avatar_default', 'gabriel_random_avatar', 99, 2 );