Hello again.
I have been searching for how to exclude the current logged in user from the members widget. I just came across Brajesh’s great post https://buddydev.com/buddypress/hiding-users-on-buddypress-based-site/ that shows how to do it for various user IDs or roles, however I just need to exclude bp_loggedin_user_id … How can I do that?
Thanks in advance for your help as always!
Hi Alayna,
Thank you for posting. Please use the following code in your bp-custom.php and let me know if it works or not
function buddydev_exclude_users( $args ) { //do not exclude in admin if( is_admin() && ! defined( 'DOING_AJAX' ) ) { return $args; } $excluded = isset( $args['exclude'] )? $args['exclude'] : array(); if( !is_array( $excluded ) ) { $excluded = explode(',', $excluded ); } $user_ids = array( bp_loggedin_user_id() ); //user ids $excluded = array_merge( $excluded, $user_ids ); $args['exclude'] = $excluded; return $args; } add_filter( 'bp_after_has_members_parse_args', 'buddydev_exclude_users' );
Thank You
Ravi
Viewing 4 posts - 1 through 4 (of 4 total)
The topic ‘ [Resolved] Excluding current logged in user from members widget?’ is closed to new replies.
This topic is: resolved