Hi Brajesh, I’m using Who’s Online, Members and Most Visited Users BP core widgets, which are displaying all members. I find it strange that there are no options for displaying certain member types only.
I am using Member Type Generator, and would like these widgets to return members of that member type, and an option for showing another member type than your own, like if you are logged in as student, only teachers are displayed, and the opposite.
How do I achieve this?, perhaps Member Types Pro is the solution?
Regards
CarstenHi Carsten,
Please seeRegards
BrajeshHi again, I tested the first code based on gender, but it didn’t make any changes in my Members list, which are still showing both genders.
Best
Carstenfunction buddydev_filter_by_opposite_member_type( $args ) { // No need to change members listing if the user is not logged in. if ( ! is_user_logged_in() ) { return $args; } // Map of visible member types based on the member type. // 'male', 'female' are member type names. $visible_types_map = array( 'male' => 'female', 'female' => 'male', ); $member_type = bp_get_member_type( get_current_user_id(), true ); // If the user does not have a member type // or if the user does not need the restriction. if ( empty( $member_type ) || empty( $visible_types_map[ $member_type ] ) ) { return $args; } $args['member_type'] = $visible_types_map[ $member_type ]; return $args; } add_filter( 'bp_after_has_members_parse_args', 'buddydev_filter_by_opposite_member_type' );
Hi Carsten,
1. Since BuddyPress member lists don’t have context, It will work for all list.2. You will need to map the member type correctly in $visible_types_map
Please check your registered member type names(unique names) and use that.
Regards
BrajeshHi Carsten,
Thank you for confirming.What is Most visited widget? Is it the one from recent visitors plugin?
Regards
BrajeshHi Carsten,
The plugin does not support member type currently. I will look into it today and update you if we are able to provide an update soon or not.Thank you
Brajesh
You must be logged in to reply to this topic.