hello when i connected i have all gender in member page https://hobjectifhallal.com/membres/
Can you test an profile please?
You susbcribe in site and test please.
thanksHi,
I am sorry but I am not sure of the issue.
Here is the code I added to your bp-custom.php// For showing members of opposite gender. function buddydev_exclude_same_gender_users( $args ) { if ( ! is_user_logged_in() ) { return $args; } $field_id = 3;// gender field. $data = maybe_unserialize( BP_XProfile_ProfileData::get_value_byid( $field_id, get_current_user_id() ) ); if ( empty( $data ) ) { return $args; } // we have two choices here. // show opposite gender or show all members who are not of same gender // I am going with opposite gender, feel free to adapt. $search = ''; if ( 'Un Homme' == $data ) { $search = 'Une Femme'; } elseif ( 'Une Femme' == $data ) { $search = 'Un Homme'; } if ( empty( $search ) ) { return $args; } $args['xprofile_query'] = array( array( 'field' => $field_id, // field id or name. 'value' => $search, 'compare' => '=', ), ); return $args; } add_filter( 'bp_after_has_members_parse_args', 'buddydev_exclude_same_gender_users' );
It looks into the field 3 3 of the logged in user, then checks for who should be shown.
Since I do not understand the language, The string values may be incorrect . Can you please check it and tell me if it is correct or not?
if ( 'Un Homme' == $data ) { $search = 'Une Femme'; } elseif ( 'Une Femme' == $data ) { $search = 'Un Homme'; }
Regards
Brajesh
You must be logged in to reply to this topic.
This topic is: resolved