This topic has 7 replies, 3 voices, and was last updated 9 years by Abe.

  • Author
  • #39293
     webpixel
    Participant

    Hello again.

    I use code below to only show – Opposite sex.
    But when i Search for anything in “Memberlist by using the form” it shows both SEX.
    How can i make it only show opposite sex even when searching?

    COPY CODE
    
    class BP_Custom_User_Ids {
     
        private $custom_ids = array();
     
        public function __construct() {
     
            $this->custom_ids = $this->get_custom_ids();
     
            add_action( 'bp_pre_user_query_construct',  array( $this, 'custom_members_query' ), 1, 1 );
            add_filter( 'bp_get_total_member_count',    array( $this, 'custom_members_count' ), 1, 1 );
     
        }
     
    private function get_custom_ids() {
        global $wpdb;
     
        //figure out if the logged-in user is male or female
       $sex = xprofile_get_field_data( 3, bp_loggedin_user_id() );
     
       if ( $sex == 'SugarDaddy' ) 
          $query = "SELECT user_id FROM {$wpdb->prefix}bp_xprofile_data WHERE field_id = 3 AND value = 'SugarBabe'";
       else 
          $query = "SELECT user_id FROM {$wpdb->prefix}bp_xprofile_data WHERE field_id = 3 AND value = 'SugarDaddy'";          
     
        $custom_ids = $wpdb->get_col( $query );
     
        return $custom_ids;
    }
     
        function custom_members_query( $query_array ) {
     
            $query_array->query_vars['include'] = $this->custom_ids;
     
        }  
     
        function custom_members_count ( $count ) {
     
            $new_count = count( $this->custom_ids );
            return $new_count;
     
        }
    }
     
    function custom_user_ids( ) {
     
        new BP_Custom_User_Ids ();
     
    }
     
    add_action( 'bp_before_directory_members', 'custom_user_ids' );
    #39309
     Laura
    Moderator

    Hello, the form is made to search for, this code only hides it from member directory, maybe you could just delete searching for gender, or use any field conditional plugin.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    Laura Solanes - Graphic Designer and Web Designer

    Please be patient as I try to answer each topic as fast as i can.

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Always happy to help you 🙂

    #39331
     webpixel
    Participant

    But this happens, if i just search for Age. (the build in “Age to Age” field)

    #39333
     Laura
    Moderator

    Hello, this is something that needs to be changed in with extra programming so i suggest to hire a developer to do this for you.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    Laura Solanes - Graphic Designer and Web Designer

    Please be patient as I try to answer each topic as fast as i can.

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Always happy to help you 🙂

    #39711
     webpixel
    Participant

    Who can i hire, that can make this?

    #40085
     Abe
    Keymaster

    hi Webpixel, right now we can’t take custom work. For now try a site like Envato Studio or any freenlancer service

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

    #41937
     webpixel
    Participant

    Okay thank you.

    Can you tell me what variable checks what membership ID the profile have been assigned from Membership pro?

    #42258
     Abe
    Keymaster

    here it is:
    pmpro_getMembershipLevelForUser($user_id);

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

Viewing 8 posts - 1 through 8 (of 8 total)

The forum ‘Sweetdate – WordPress’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?