Support Forums

The forums are closed and will be removed when we launch our new site.

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

Forums Forums Search Search Results for 'function sf_input_object_pre'

Viewing 7 results - 111 through 117 (of 117 total)
  • Author
    Search Results
  • #48863

    Jon Watson
    Participant

    GOT IT!

    Just trying to figure out why my “All authors” label is now missing, but the names are showing up properly! Was just missing the “->value” after the $option above:

    function filter_function_name($input_object, $sfid) {
    
    	if ($input_object['name'] == '_sft_author') {
    
    		global $coauthors_plus;
    		
    		//udpate this field before rendering
    
    			foreach($input_object['options'] as $key => $option) {
    
    				$user = $coauthors_plus->get_coauthor_by( 'user_nicename', $option->value );
    
        			$input_object['options'][$key]->label = $user->display_name;
    
            	}
    
    	}
    	
    	return $input_object;
    
    }
    
    add_filter('sf_input_object_pre', 'filter_function_name', 10, 2);

    Will post back in a few with final code, once I’ve figured out where my main label has gone!

    #48858

    Jon Watson
    Participant

    Whoops! Nope, being an idiot. Ignore what I said about input taxonomy. That was a load of old hogswash. Would help if slowed down for a second to realise just how the filter (and the plugin) worked!

    Getting closer:

    function filter_function_name($input_object, $sfid) {
    
    	if ($input_object['name'] == '_sft_author') {
    
    		global $coauthors_plus;
    		
    		//udpate this field before rendering
    
    			foreach($input_object['options'] as $key => $option) {
    
    				$user = $coauthors_plus->get_coauthor_by( 'user_nicename', $option );
    
        			$input_object['options'][$key]->label = $user->display_name;
    
            	}
    
    	}
    	
    	return $input_object;
    
    }
    
    add_filter('sf_input_object_pre', 'filter_function_name', 10, 2);
    #46666

    In reply to: Dynamic slider range


    Ross
    Keymaster

    Hey Arek

    I’ve just done a quick update to the plugin which should allow you to change the slider min / max settings (not their actual values).

    Install the update I’ve just emailed to you, by following:

    1) disable S&F (do not delete via wp-admin)
    2) via FTP upload and replace the existing S&F in – wp-content/plugins/search-filter-pro/
    3) enable S&F via wp-admin

    After this you can use the following filter to change the min max:

    
    function change_slider_min_max($input_object, $sfid)
    {
    	if(($input_object['name']=='_sfm__price')&&(($input_object['type']=='range-slider')||($input_object['type']=='range-number')))
    	{
    		$input_object['attributes']['data-min'] = 10;
    		$input_object['attributes']['data-max'] = 200;
    		
    	}
    	
    	return $input_object;
    }
    add_filter('sf_input_object_pre', 'change_slider_min_max', 10, 2);

    Check here for a full example of how to use the filter:

    https://gist.github.com/rmorse/7b59b45a14b1ca179868

    Thanks

    #45837

    In reply to: Pre-select Author


    Trevor
    Moderator

    Ah, that’s better 🙂

    I think you could use the sf_input_object_pre filter in your theme’s functions.php file, as shown here:

    http://www.designsandcode.com/documentation/search-filter-pro/action-filter-reference/

    You might also find references to that filter in a search of this forum where others will have used it. The problem would be that it would have to be different for every page in the profiles and I do not see how you could do that.

    #40004

    Daniel Osorio
    Participant

    Perfect,

    I’ve done it… it works great. Thank you!

    For someone curious about how to implement this, on your plugin php add the following function:

    function my_plugin_search_filter_change_label($input_object, $sfid) {
      if ($sfid == 12345 && $input_object['name'] == '_sf_post_type') {
        foreach ($input_object['options'] as $key => $option) {
          if ($option->label == 'Media') {
            $input_object['options'][$key]->label = 'Photos';
          }
        }
      }
      return $input_object;
    }
    add_filter('sf_input_object_pre', 'my_plugin_search_filter_change_label', 10, 2);

    Hope it helps.

    #34366

    Ross
    Keymaster

    Hi Jacob sorry for the delay.

    You’re almost there.

    First, you have only 1 = in the first if statement.

    So it does the code for every single field – this needs to be changed to a double ==

    Second, I think likely you got the fieldname wrong – see here on how to get the correct fieldname:

    http://www.designsandcode.com/documentation/search-filter-pro/accessing-search-data/#How_to_get_the_field_name

    Here is your code updated (and I’m guessing the field name is from meta data, otherwise you need to find the name as link just above:

    <?php
    function filter_input_object($input_object, $sfid) {
    	
    	if(($input_object['name'] == '_sfm_workshop_location')) {
    		
    		foreach($input_object['options'] as $option) {
    			$option->label = get_the_title($option->value);
    		}
    		
    		return $input_object;
    	}
    	else {
    		
    		return $input_object;
    	}
    }
    add_filter('sf_input_object_pre', 'filter_input_object', 10, 2);
    
    ?>

    Thanks

    #34365

    Jacob James
    Participant
    This reply has been marked as private.
Viewing 7 results - 111 through 117 (of 117 total)