Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on May 17th, 2010  |  syntax: PHP  |  size: 0.85 KB  |  views: 223  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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 );