Hello.I need a function: Show Opposite Gender Base on XProfile https://buddydev.com/support/forums/topic/show-opposite-gender-base-on-xprofile/ for buddypress.
Function opposite by member type, It doesn’t suit me.
https://buddydev.com/show-only-users-of-opposite-genders-on-buddypress-site/
Maybe I searched badly, and there is a code Show Opposite Gender Based on XProfile, for buddypress?Hello Roman,
Welcome to the BuddyDev Forum. Please look at here:
https://pastebin.com/mEPhWikKA solution is posted for xprofile field. But, It works with the BuddyBoss Platform and makes it compatible with BuddyPress. Please remove the function ‘bp_get_xprofile_gender_type_field_id’ and use your gender field ID or field name and replace ‘his_Male’ and ‘her_Female’ with your gender field value.
Give it a try and let me know.
Regards
RaviI did this ‘$opposite_gender = $this->get_opposite_gender( bp_loggedin_user_id() );
if ( $opposite_gender ) {
$query->query_vars[‘xprofile_query’] = array(
array(
‘field’ => 47,
‘value’ => $opposite_gender,
‘compare’ => ‘=’,
),
);
}
}’
Does not display anyone.Hi Roman,
Are you using BuddyBoss? If yes, you will need to change the values in
get_opposite_gender
method for the male/female.Regards
BrajeshHi Roman,
I am sorry, if you are using BuddyPress, the snippet will work fine. Please make sure the option values in your Gender field matches “Male” and “Female” as it is case sensitive.Regards
Brajesh
The topic ‘ [Resolved] Opposite genders’ is closed to new replies.