Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Custom avatars arent showed on single blogs in WPMU


Anna Ladoshkina
Participant

@foralien

If it’s still actual – I have a temporary solution

This problem occurs because in 1.2.4 has been change the approach to how the avatars paths constract – now the BP rely on wp_upload_dir() function. That is pretty well on single-site installation or in the root blog of multisite installation (at least at wp 2.9.2) but in users blog (not root) it returns the wrong path. That’s why if you use bp-powered avatars in user-blogs (not main) you see the gravatar instead.

For my installation I’ve written two filters to fix this (please grab the code below and put it into your bp-custom.php) – they are tested with WPMU 2.9.2 (subdirectories) and BP 1.2.4 with default upoad path (for example for member avatar it should be – path to wp-content/blogs.dir/1/files/avatars/user_id/avatar-file.jpg)


function nfm_bp_avtar_upload_path_correct($path){
if ( bp_core_is_multisite() ){
$path = ABSPATH . get_blog_option( BP_ROOT_BLOG, 'upload_path' );
}
return $path;
}
add_filter('bp_core_avatar_upload_path', 'nfm_bp_avtar_upload_path_correct', 1);

function nfm_bp_avatar_upload_url_correct($url){
if ( bp_core_is_multisite() ){
$url = get_blog_option( BP_ROOT_BLOG, 'siteurl' ) . "/files";
}
return $url;
}
add_filter('bp_core_avatar_url', 'nfm_bp_avatar_upload_url_correct', 1);

Hope, that would help :)

Skip to toolbar