[Plugin: BuddyPress Groupblog] Adding an entry to group activity stream.
-
Hi all. I hope this help to solve the known issue.
To add the groups’ blog posts to activity stream I first set the group id as a blog option throw $meta when creating a new blog with wpmu_create_blog on bp-groupblog.php (lines 756 and 782). (Will be good create a function to do this to all groups that already have blogs).
Then I added the follow to the bp-groupblog.php (I use “get_option( ‘group_id’ )” to get the info I added above):
function bp_groupblog_record_publish_post_activity( $post_id ) { global $bp; $post = get_post( $post_id ); $group_id = get_option( 'group_id' ); if ( !$group_id ) return; $group = new BP_Groups_Group( $group_id, true ); $activity_action = sprintf( __( '%s published the post %s in the group %s:', 'buddypress'), bp_core_get_userlink( $post->post_author ), '<a href="' . get_permalink( $post->ID ) .'">' . attribute_escape( $post->post_title ) . '</a>', '<a href="' . bp_get_group_permalink( $group ) . '">' . attribute_escape( $group->name ) . '</a>' ); $activity_content = bp_create_excerpt( $post->post_content ); /* Record this in activity streams */ $r = groups_record_activity( array( 'action' => apply_filters( 'bp_blogs_activity_new_grouppost_action', $activity_action, $post->post_content, &$post ), 'content' => apply_filters( 'bp_blogs_activity_new_grouppost_content', $activity_content, $post->post_content, &$post ), 'primary_link' => apply_filters( 'bp_blogs_activity_new_grouppost_primary_link', get_permalink( $post->ID ) ), 'type' => 'new_groupblog_post', 'item_id' => $group_id, 'secondary_item_id' => $post->post_author, 'hide_sitewide' => 0 ) ); } add_action( 'publish_post', 'bp_groupblog_record_publish_post_activity' );
That’s all.
Viewing 13 replies - 1 through 13 (of 13 total)
Viewing 13 replies - 1 through 13 (of 13 total)
- The topic ‘[Plugin: BuddyPress Groupblog] Adding an entry to group activity stream.’ is closed to new replies.