• Hello, Happy Holidays!

    Is it possible to have a “Select All” button on the search for fields with multiple choices? I am creating some fields with as many as 15 choices and having to check one by one to select all is not desirable. Any guidance for this is appreciated.

    • This topic was modified 1 year, 11 months ago by briancraw.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Andrea Tarantini

    (@dontdream)

    Hello Brian, Happy Holidays!

    You can try this:

    A) Open file wp-content\plugins\bp-profile-search\templates\members\bps-form-default.php

    B) Locate the lines:

    	break;
    	case 'checkbox':
    ?>
    

    C) Replace them with:

    	break;
    	case 'checkbox':
    ?>
    			<script>
    				jQuery(function ($) {
    					$('#<?php echo $id; ?>_all').on('click', function () {
    						$('#<?php echo $id; ?>_wrap input[type="checkbox"]').prop('checked', this.checked)
    					})
    				});
    			</script>
    			<label><input type="checkbox" id="<?php echo $id; ?>_all"> Select All</label><br>
    

    D) Save the file, and copy it to the buddypress/members directory in your active theme’s root.

    Thread Starter briancraw

    (@briancraw)

    This works great! Thank you.

    Another option I would like to implement is that dependent on the gender of the user doing the search, results would only be returned for the opposite gender. So if a a user has selected male in their profile when using the search form only users who are female will be returned as results using the other data on the form.

    Plugin Author Andrea Tarantini

    (@dontdream)

    You can add this code to your bp-custom.php file:

    add_filter ('bps_hidden_filters', 'my_hidden_filter');
    function my_hidden_filter ($filters)
    {
    	$user_id = bp_loggedin_user_id ();
    	if ($user_id != 0)
    	{
    		$gender = xprofile_get_field_data (247, $user_id);
    		if ($gender == 'Male')
    			$filters['field_247'] = 'Female';
    		else if ($gender == 'Female')
    			$filters['field_247'] = 'Male';
    		else
    			$filters['field_247'] = 'none';
    	}
    	return $filters;
    }

    Replace 247 with the actual field ID of your gender profile field, and Male and Female with its actual values.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Check All’ is closed to new replies.