Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Getting Buddypress avatars the right way?


Xevo
Participant

@xevo

function xe_loggedin_user_avatar($type = "", $width = "", $height = "") {
global $bb_current_user;
$userID = $bb_current_user->ID;
$files = "";
if ($handle = opendir('/var/www/vhosts/tsukai.nl/httpdocs/wp-content/uploads/avatars/' . $userID)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
if($type == "thumb") {
if(substr($file, -11, 7) == "bpthumb" ) {
$files .= $file;
}
} elseif($type == "full") {
if(substr($file, -10, 6) == "bpfull" ) {
$files .= $file;
}
}
}
}
closedir($handle);
}

echo '<img src="http://tsukai.nl/wp-content/uploads/avatars/' . $userID . '/' . $files . '" width="' . width . '" height="' . $height . '" />';
}

This is the solution I came up with, again, if anyone has a better solution, do tell.

Skip to toolbar