in PHP, Wordpress

Buddypress avatars not shown in Cometchat after upgrade to WordPress 3.0

I was having problems showing the Buddypress avatars in Cometchat after upgrading to version 3.0 of WordPress. Instead of showing the Buddypress avatars, Cometchat was showing a Gravatar.

Looks like the problem is that WordPress 3.0 has a different directory structure and Cometchat can’t locate the files anymore.

To solve this I had to change the getAvatar function in cometchat/config.php file:

function getAvatar($data) {
	$data = explode('|',$data);
	$id = $data[0];
	$blog = 1;
	if (is_dir((dirname(dirname(__FILE__)).'/wp-content/blogs.dir/' . $blog . '/files/avatars/' . $id))) {
		$files = "";
		if ($handle = opendir(dirname(dirname(__FILE__)).'/wp-content/blogs.dir/' . $blog . '/files/avatars/' . $id)) {
			while (false !== ($file = readdir($handle))) {
				if ($file != "." && $file != "..") {
					if(substr($file, -11, 7) == "bpthumb" ) {
						$files .= $file;
		if (file_exists((dirname(dirname(__FILE__)).'/wp-content/blogs.dir/' . $blog . '/files/avatars/' . $id . '/' . $files))) {
			return '/files/avatars/' . $id . '/' . $files;
	return ''.md5($data[1]).'?d=wavatar&s=80';

The $blog should be the id of your blog/site showing Cometchat. If you have multiple sites in a single WordPress installation showing Cometchat, you may need to make some changes here to make this variable dynamic.

Write a Comment


  1. hi, try to use bp_core_fetch_avatar

    bp_core_fetch_avatar( array(“item_id”=>$id,”type”=>”full”) );

    change the type of the returned image.

    can you send me your config.php i need the friendlist function function my email is [email protected].

    thanks :).


  • October 13, 2010

    Windows 7 sound scheme for xp download

    The next time I read a blog, Hopefully it won\’t disappoint me as much as this one. I mean, I know it was my choice to read, however I truly believed you would have something useful to talk about. All I hear is a bunch of whining about something that…