Skip to content

Instantly share code, notes, and snippets.

Created March 3, 2016 17:18
Show Gist options
  • Save imath/91d56292673e6de61597 to your computer and use it in GitHub Desktop.
Save imath/91d56292673e6de61597 to your computer and use it in GitHub Desktop.
Share the same uploads dir for a BuddyPress multiblog set up
* Multiblog must have been set for it to work :)
* eg: define( 'BP_ENABLE_MULTIBLOG', true );
function rbaccaro_set_multiblog_shared_upload_dir() {
if ( ! bp_is_multiblog_mode() ) {
$current_site = get_current_site();
if ( (int) bp_get_root_blog_id() !== (int) $current_site->blog_id ) {
$switched = true;
switch_to_blog( $current_site->blog_id );
buddypress()->upload_dir = wp_upload_dir();
if ( ! empty( $switched ) ) {
add_action( 'bp_init', 'rbaccaro_set_multiblog_shared_upload_dir', 1 );
Copy link

rbaccaro commented Mar 3, 2016

Hi @imath,

That worked just fine.

Thank you again,

Copy link

@imath I've tried this great looking piece of code on my multiblog but it does not work, it shows a grey area on the main site and subsite after uploading an image.

Is there a fix for this?

Copy link

thanks, thought I'd just mention this still works

Copy link

Just chiming in to say this worked like a charm. Thank you!!

Copy link


Thanks so much for creating this plugin. Can I get a couple of tips please to get it working? So far, I have done the following, but Cover Photos and Avatar images are still not syncing for the Groups and Members.

Here is what I've tried so far:

  1. Activated Multiblog with define( 'BP_ENABLE_MULTIBLOG', true );
  2. Made a new directory in main directory>Plugins>bp-custom
  3. Created a new text file and pasted your code above.

However the solution is not working at the moment. Any ideas how to fix? I would really appreciate your guidance on this.

Thanks very much. 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment