Created
May 31, 2012 22:34
-
-
Save sbrajesh/2846830 to your computer and use it in GitHub Desktop.
Propagate post recording to activity from sub site to main site
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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