Forums Forums Search & Filter Pro Set Default Radio box checked to different category

Viewing 10 posts - 1 through 10 (of 11 total)
  • Anonymous
    #203242

    Hi,

    I have categories in a radio box fields but they have only styling of checkboxes functionality wise they work as radio box, I want to set radio box checked to different category as a default at present it set default to all categories i want to set radio box checked to WordPress themes as a default, is there a way to achieve this

    Please have a look at attached video url link

    url of site: url

    Thanks

    Trevor
    #203245

    I understand what you need, and it has been asked for before. It is possible to set the default, but it does not alter the results shown until a search is done. V3 should have the option of setting the default and it affecting the results.

    The problem with setting the default is that the same code (it has to be done either with JavaScript post page load, or by PHP pre-form load using our filter input objects filter) tends to override any choices made by the user.

    Anonymous
    #203255
    This reply has been marked as private.
    Trevor
    #203262

    As I have no snippets to hand, I have asked Ross, the plugin developer, if he can provide you an example.

    Anonymous
    #203267
    This reply has been marked as private.
    Trevor
    #203272
    This reply has been marked as private.
    Ross Moderator
    #203304

    Hi there

    I understand the scenario.

    We have a filter, to change the default in the search form, but this won’t affect the results.

    This would be the code (untested ofc):

    function filter_input_object_categories($input_object, $sfid){
    
    	//ensure we are only filtering the correct field name - in this case the field we want to filter has the name <code>_sft_marketplace</code>
    	if($input_object['name']!='_sft_marketplace'){
    		return $input_object;
    	}
    	
    	//manually set the values shown/selected in the field - must be array even if single value
    	//this should really only occur under specific conditions, otherwise your field will be permanently set to this value
    	
    	//if the field is not already in use / selected
    	if(!isset($_GET['_sft_marketplace'])){
    		//then set it to "best wordpress app themes"
    		$input_object['defaults'] = array("best-wordpress-app-themes");
    	}
    	return $input_object;
    }
    add_filter('sf_input_object_pre', 'filter_input_object_categories', 10, 2);

    Thanks

    Anonymous
    #203490
    This reply has been marked as private.
    Ross Moderator
    #203662

    Hi there

    Do you mean the results do not reflect the new “default” we are setting?

    Thanks

    Anonymous
    #203938
    This reply has been marked as private.
Viewing 10 posts - 1 through 10 (of 11 total)