Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function rogerthat_adminmods_only( $query, $sql_parts ) {
- global $wpdb;
- // Only do stuff if the user parameter was set
- if ( empty( $sql_parts['user'] ) )
- return $query;
- // Add a requirement that the matched user is an admin or a moderator of a group
- $sql_parts['user'] .= $wpdb->prepare( ' AND (m.is_admin = 1 || m.is_mod = 1 )' );
- // Rebuild and return the SQL
- return join( ' ', (array) $sql_parts );
- }
- // 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.
- // YMMV; this may also stomp over any other plugins that affect the Groups' SQL queries directly.
- add_filter('bp_groups_get_paged_groups_sql', 'rogerthat_adminmods_only', 20, 2);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment