Skip to content

Instantly share code, notes, and snippets.

Created Mar 3, 2016
What would you like to do?
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

eskadesign commented Sep 7, 2017

@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

trivendor commented May 6, 2019

thanks, thought I'd just mention this still works

Copy link

i-am-abell commented Apr 29, 2022

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

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