Advertisement
Guest User

Untitled

a guest
May 17th, 2010
490
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.85 KB | None | 0 0
  1. function filter_blog_activity_by_category( $a, $activities ) {
  2.     global $bp;
  3.    
  4.     if ( is_site_admin() )
  5.         return $activities;
  6.    
  7.     foreach ( $activities->activities as $key => $activity ) {
  8.         if ( $activity->component == 'blogs' ) {
  9.             $blog_id = $activity->item_id;
  10.             $post_id = $activity->secondary_item_id;
  11.             switch_to_blog( $blog_id );
  12.             // Pull up the post using $post_id and get_post()
  13.             // Get the categories with get_the_category()
  14.             // If the post is in the excluded categories, then
  15.                 unset( $activities->activities[$key] );
  16.             restore_current_blog();
  17.         }
  18.     }
  19.            
  20.     /* Renumber the array keys to account for missing items */
  21.     $activities_new = array_values( $activities->activities );
  22.     $activities->activities = $activities_new;
  23.     return $activities;
  24. }
  25. add_action( 'bp_has_activities', 'filter_blog_activity_by_category', 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement