BuddyDev

Search

[Resolved] conditionsprofile field (if i am a women, i search man)

  • Participant
    Level: Enlightened
    Posts: 34
    bootz on #21644
    This reply has been marked as private.
  • Participant
    Level: Enlightened
    Posts: 34
    bootz on #21646
    This reply has been marked as private.
  • Participant
    Level: Enlightened
    Posts: 34
    bootz on #21662

    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.
    thanks

  • Keymaster
    (BuddyDev Team)
    Posts: 24636
    Brajesh Singh on #21684

    Hi,
    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

  • Participant
    Level: Enlightened
    Posts: 34
    bootz on #21692
    This reply has been marked as private.
  • Participant
    Level: Enlightened
    Posts: 34
    bootz on #21709
    This reply has been marked as private.
  • Keymaster
    (BuddyDev Team)
    Posts: 24636
    Brajesh Singh on #21743
    This reply has been marked as private.
  • Participant
    Level: Enlightened
    Posts: 34
    bootz on #21765
    This reply has been marked as private.
  • Participant
    Level: Enlightened
    Posts: 34
    bootz on #21842
    This reply has been marked as private.
  • Keymaster
    (BuddyDev Team)
    Posts: 24636
    Brajesh Singh on #21852
    This reply has been marked as private.

You must be logged in to reply to this topic.

This topic is: resolved