Using add_filter with Combobox?

Forums › Forums › Search & Filter Pro › Using add_filter with Combobox?

Viewing 7 posts – 1 through 7 (of 7 total)
  • Anonymous
    #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
    #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.

    Anonymous
    #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
    #235087

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

    Anonymous
    #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
    #235120

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

    Anonymous
    #235122

    Sure, no problem

Viewing 7 posts – 1 through 7 (of 7 total)
Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.