BuddyDev

Search

[Resolved] Opposite genders

  • Participant
    Level: Initiated
    Posts: 6
    Roman on #51072

    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?

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #51082

    Hello Roman,

    Welcome to the BuddyDev Forum. Please look at here:
    https://pastebin.com/mEPhWikK

    A 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
    Ravi

  • Participant
    Level: Initiated
    Posts: 6
    Roman on #51087

    I have a Gender dropdown field, field_id=47. I replaced ‘his_Male’ and ‘her_Female’ with Male and Female. How to correctly change ‘field’ => bp_get_xprofile_gender_type_field_id(), // field id or name, to field_id=47?

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #51088

    Hello,

    Try the following way

    
    'field' => 47
    
    

    Please check

    Regards
    Ravi

    • This reply was modified 11 months, 1 week ago by Ravi.
  • Participant
    Level: Initiated
    Posts: 6
    Roman on #51090

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

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #51091

    Hello Roman,

    Please share your complete code so that I can check. Please Use (`) before and after the code.

    Regards
    Ravi

  • Participant
    Level: Initiated
    Posts: 6
    Roman on #51093
  • Keymaster
    (BuddyDev Team)
    Posts: 24611
    Brajesh Singh on #51104

    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
    Brajesh

  • Participant
    Level: Initiated
    Posts: 6
    Roman on #51107

    I’m making my first website. This code works with Buddyboss, but I don’t like this plugin, it’s slow. With Buddyboss, only the Buddux template works normally. And Buddypress is fast, any template is suitable.

  • Keymaster
    (BuddyDev Team)
    Posts: 24611
    Brajesh Singh on #51110

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

This topic is: resolved