I want to keep my site’s theme consistent. I’m making a site for a Star Wars: The Old Republic guild. I’ve got 156 avatars. Ideally, I’d like users to be able to choose from these avatars in addition to uploading one of their own. But let’s start with something even easier. If they don’t have a custom avatar, instead of default to Mystery Man, I’d like to default to one randomly chosen from the 156. Could I just do something like this:
$tmp = glob('avatars/*.gif');
if (is_array($tmp))
{
$flist = array_merge($flist,$tmp);
}
$default_avatar = $flist[array_rand($flist)];
add_filter( 'bp_core_mysteryman_src', $default_avatar );
My fear in trying this out, is that every time it displayed any default avatar if would pick one at random. What I’d like is to do the randomization once in assigning an avatar to a user if they don’t have one.