Guest User

Untitled

a guest
Mar 3rd, 2012
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.77 KB | None | 0 0
  1. <?php
  2. function rogerthat_adminmods_only( $query, $sql_parts ) {
  3.   global $wpdb;
  4.  
  5.   // Only do stuff if the user parameter was set
  6.   if ( empty( $sql_parts['user'] ) )
  7.     return $query;
  8.  
  9.   // Add a requirement that the matched user is an admin or a moderator of a group
  10.   $sql_parts['user'] .= $wpdb->prepare( ' AND (m.is_admin = 1 || m.is_mod = 1 )' );
  11.  
  12.   // Rebuild and return the SQL
  13.   return join( ' ', (array) $sql_parts );
  14. }
  15.  
  16. // You will need to add_filter just before you want to make your special group query, and remove_filter just after, otherwise it'll affect all BP Groups loops.
  17. // YMMV; this may also stomp over any other plugins that affect the Groups' SQL queries directly.
  18. add_filter('bp_groups_get_paged_groups_sql', 'rogerthat_adminmods_only', 20, 2);
  19. ?>
Advertisement
Add Comment
Please, Sign In to add comment