Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Propagate post recording to activity from sub site to main site
add_action('save_post','bpdev_record_post_on_main_site',20,2);
function bpdev_record_post_on_main_site($post_id, $post, $user_id = 0 ) {
global $bp, $wpdb;
$post_id = (int)$post_id;
$blog_id = (int)$wpdb->blogid;
if($blog_id==1)
return;//it is recording main site and we don't have to worry about it
switch_to_blog(1);//switch to main site
bp_blogs_record_post($post_id,$post,$user_id);
restore_current_blog();//restore current blog
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.