Avatar across multisite
-
I have been yearning for the feature where it is able to use one avatar for users across all sites in multisite.
Hope that can be done.
Please help.
Thanks.
-
hi,
Been trying to set this up for a few days now, but no success. I’ve setup a multi-site network with sub-directories and buddypress network activated.
I’ve added define( ‘BP_ENABLE_MULTIBLOG’, true ); to config.php as recommanded for BP multisite install.Main site: mydomain.com
subsite: mydomain.com/subsiteWhen users upload their profile picture on main site, unfortunately it doesn’t sync with their profile when they go on the subsite.
The following codes have worked for some people but not for me. Still trying to find a solution.
function bpdev_fix_avatar_dir_path( $path ){
if ( is_multisite() && BP_ENABLE_MULTIBLOG )
$path = ABSPATH . ‘wp-content/uploads/’;
return $path;
}
add_filter( ‘bp_core_avatar_upload_path’, ‘bpdev_fix_avatar_dir_path’, 1 );
//fix the upload dir url
function bpdev_fix_avatar_dir_url( $url ){
if ( is_multisite() )
$url = network_home_url(‘/wp-content/uploads’) ;
return $url;
}
add_filter( ‘bp_core_avatar_url’, ‘bpdev_fix_avatar_dir_url’, 1 );I know it’s not quite what you’re looking for, but you could always just disable profile uploading in Buddypress’ settings and encourage your users to set up a Gravatar account.
Thought about that solution too but i do not want my users to create 2 accounts just to sign up on my site.
I have the same issue and wishes. I tried the code you provided above but it did not work.
Finally found a solution.
1) add define( ‘BP_ENABLE_MULTIBLOG’, true ) in wp-content/config.php
2) network activate buddypress
3) install rmiweb-multisite-avatar. It is a custom plugin for rmi.one website not available on wordpress repository. Can’t remember from where i grabbed it but i’ve uploaded it on my uptobox account => http://uptobox.com/543ii9u4ozoh
4) At first it wasn’t working for me on my subsite because the theme (skywarriorthemes.com/arcane/) had an issue with displaying avatar. But i’ve tried it with other 3rd party themes and wordpress default twenty seventeen and it works like a charm. So make sure that your theme is not creating some conflict too like mine did.
5) If you want to completely disable gravatar: https://wordpress.org/plugins/disable-user-gravatar/
6) Profit.Hope that helps.
that worked! Livesaver!
Nice. Happy i could help!
Thanks for the responses.
I have tried your steps @deadlinkd, but unfortunately it didn’t work for me.
I found a simple solution.
After activating multisite I installed and network activated BuddyPress.
I also added this line to wp-config.php: define ( ‘BP_ROOT_BLOG’, 2 )It works perfect, just the way i wanted it.
Thanks, you all.
This works for me, althouh it took me a bit before I realized BP_ROOT_BLOG was not defined.
In my case, when I checked, it was ID 1, so I defined it accordingly.?>
<?php
//echo get_current_blog_id();//echo ABSPATH . “<BR>”;
//echo get_site_url() . “<BR>”;
if ( !defined( ‘BP_ROOT_BLOG’ ))
define( ‘BP_ROOT_BLOG’, 1);// echo “There is no root blog defined “;
// echo get_blog_option( 3, ‘siteurl’ ) . “wtf”;
/* This fixes the Multisite avatar problem */
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’ ) . “/wp-content/uploads”;}
return $url;
}
add_filter(‘bp_core_avatar_url’, ‘nfm_bp_avatar_upload_url_correct’, 1);
?>
- You must be logged in to reply to this topic.