Drop down field to multi select

BP Profile Search Drop down field to multi select

  • Author
    Post
  • #8834 Reply
    Muhammad Rahman
    Guest

    Hi Andrea,

    First and foremost, this is an amazing piece of work. So cleverly done. I am impressed. Thank you.

    Secondly, I have a member city/country etc as drop down list. But when I search I want user to select multiple cities/countries. How can I achieve that please. I was hoping the ‘range’ option intelligently make that happen but it seems its only for number now.

    Thank you in advance for your valuable time.

    Muhammad.

    #8836 Reply
    Muhammad Rahman
    Guest

    I have managed to sort it out. Anyone interested, drop me a line to mmrs151@gmail.com

    Thanks.

    #8838 Reply
    Muhammad Rahman
    Guest

    hmm, but I have a concern though.

    I can move the legacy template to members directory as I have customisation to support my case but I also have customisation in
    bps-teamplates47:

    		if ($meta['field_mode'][$k] == 'range')  {
    			$f->display = 'range';
    			$f->type = bps_displayXsearch_form ($f);
    		} elseif ($meta['field_mode'][$k] == 'multiselect') {
    			$f->display = 'multiselect';
    			$f->type = bps_displayXsearch_form ($f);
    		}

    bps-xprofile
    'selectbox' => array ('' => 'normal', 'range' => 'range', 'multiselect' => 'multiselect'),

    	if ($f->filter == 'range') {
    		if ($type == 'datebox') {
    			return 'age_range';
    		} elseif ($type == 'selectbox') {
    			return 'multiselectbox';
    		} else {
    			return 'range';
    		}
    	}

    etc …
    which means plugin updates will break them.

    What would you suggest please.

    Thanks in advance

    #8839 Reply
    Muhammad Rahman
    Guest
    elseif ($type == 'selectbox') {
        return 'multiselectbox';
    } 

    sorry that was a debug code. It looks like this though,

    
    	if ($f->filter == 'multiselect') {
    		if ($type == 'selectbox') {
    			return 'multiselectbox';
    		}
    	}
    
    #8992 Reply
    andrea
    Plugin Author

    Hi Muhammad,

    Sorry for the late reply!

    If you wish to change the default display of a search field, you can add this code to your file bp-custom.php:

    add_action ('bps_field_before_search_form', 'change_display');
    function change_display ($field)
    {
    	if ($field->id == 123)  $field->display = 'multiselectbox';
    }

    Replace 123 with your actual field ID.

    #9032 Reply
    Newbie
    Guest

    Hi, thanks for plugin, is great! 🙂

    Could you apply this code for change display to textbox too?

    thanks

    #9033 Reply
    andrea
    Plugin Author

    Yes, you can change the display to textbox too:

    add_action ('bps_field_before_search_form', 'change_display');
    function change_display ($field)
    {
            if ($field->id == 123)  $field->display = 'textbox';
    }
Reply to: Drop down field to multi select
My Information