Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sbrajesh/2846830 to your computer and use it in GitHub Desktop.
Save sbrajesh/2846830 to your computer and use it in GitHub Desktop.
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