Support Forums

Looking for support? You can access the support system via your account.

Forums Forums Search & Filter Pro Using add_filter with Combobox?

Viewing 7 posts - 1 through 7 (of 7 total)
  • Ryan Olton
    #234883

    Hello,

    I’m using a combobox to display / filter regions on a real estate website. How can I add a new region to the combobox via my functions.php file? Basically, I want to combine a few towns into a single option.

    I’ve used the code below to add options to a normal dropdown in the search but couldn’t get something similar to work for the combobox:

    function edit_rent_range($input_object, $sfid) {
    	if(($input_object['name']!='_sfm_rent_max')||($input_object['type']!='select'))
    	{
    		return $input_object;
    	}
    	
    	if(!isset($input_object['options']))
    	{
    		return $input_object;
    	}
    	
    	//create a new option we want to add
    	$new_last_option = new StdClass();
    	$new_last_option->value = "3000000";
    	$new_last_option->label = "$35,000+";
    	
    	//add a brand new option to the bottom
    	array_push($input_object['options'], $new_last_option);
    		
    	return $input_object;
    }
    add_filter('sf_input_object_pre', 'edit_rent_range', 10, 2);

    Any help will be appreciated.

    Trevor Moderator
    #234931

    The problem would then be how would our plugin process that choice, unless the combined option would also be attached to any posts, in which case it would already be in the options, so all you would need to is remove those towns.

    Ryan Olton
    #234995

    Thanks for the feedback. I was hoping it would be similar manually to choosing four or five towns in the combobox but instead of the user doing that, they click the new option which automatically selects those towns.

    Possible?

    Trevor Moderator
    #235087

    It is not, I am sorry, unless, as I said, that ‘combined’ value was also in the meta data for each post.

    Ryan Olton
    #235118

    Ok, thanks for the feedback. There are thousands of entries already so not really feasible to sort through all of those to add the combined option.

    Trevor Moderator
    #235120

    Ah. As you say, not feasible then. Can I close this thread?

    Ryan Olton
    #235122

    Sure, no problem

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

The topic ‘Using add_filter with Combobox?’ is closed to new replies.