If you would like to hide your administrators from the member directory, here is a simple code snippet that will do the job:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | // Remove admin from the member directory function gwangi_hide_admins_from_directory( $qs = false, $object = false ) { $excluded_user = implode( ',', get_users( 'role=administrator&fields=ID' ) ); if ( $object != 'members' && $object != 'friends' ) // hide admin to members & friends return $qs; $args = wp_parse_args( $qs ); if( ! empty( $args['user_id'] ) ) return $qs; if( ! empty( $args['exclude'] ) ) $args['exclude'] = $args['exclude'] . ',' . $excluded_user; else $args['exclude'] = $excluded_user; $qs = build_query( $args ); return $qs; } add_action( 'bp_ajax_querystring', 'gwangi_hide_admins_from_directory', 20, 2 ); |
Heads up! Don’t know how to add a PHP code snippet to your site ? If you want to find out how to add a PHP code snippet to your site, […]
Continue reading "How to Hide Admin Users in the Members Directory?" →