Share the same uploads dir for a BuddyPress multiblog set up
<?php | |
/** | |
* 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() ) { | |
return; | |
} | |
$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 ) ) { | |
restore_current_blog(); | |
} | |
} | |
add_action( 'bp_init', 'rbaccaro_set_multiblog_shared_upload_dir', 1 ); |
This comment has been minimized.
This comment has been minimized.
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? |
This comment has been minimized.
This comment has been minimized.
trivendor
commented
May 6, 2019
thanks, thought I'd just mention this still works |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
rbaccaro commentedMar 3, 2016
Hi @imath,
That worked just fine.
Thank you again,