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 'sf_input_object_pre'

Viewing 10 results - 131 through 140 (of 150 total)
  • Author
    Search Results
  • #64663

    Ash
    Participant

    Is this also work in sf_input_object_pre that you gave me?

    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(1726)->current_query();

    #64634

    Ash
    Participant

    What’s proper way to get query parameter in sf_input_object_pre?

    #64614

    Trevor
    Moderator

    This:

    sf_input_object_pre

    will allow you to modify the html elements, yes. My bad. I am not sure how you would use it in this context though.

    #64610

    Ash
    Participant

    I understand.
    BTW, Can’t I use these hook to filter dropdown?
    sf_edit_query_args or sf_input_object_pre

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

    #54735

    Canton Becker
    Participant

    Awesome! That was a huge help, thanks. In case anyone else is reading this to solve the same problem, here’s how I solved it:

    We happen to have a page-search.php template in our child theme. So, I just added this to the very top:

    
    $searchFilterID = 44867;
    add_filter('sf_input_object_pre', 'insert_search_term_into_advanced_search', 10, 2);
    
    function insert_search_term_into_advanced_search ($input_object, $searchFilterID)
    {
    	$q = isset($_GET['q']) ? htmlspecialchars($_GET['q']) : '';
    	if($input_object['name']=='_sf_search') $input_object['attributes']['value'] = $q;
    	return $input_object;
    }
    
    #54695

    olivier GUY
    Participant

    Hi,
    I would like to have the checkboxes’ checked attribute automatically set to ‘checked’, when opening the form. I use the following filter function :

    function catcheck($input_object, $sfid)
    {
    if($input_object[‘attributes’][‘type’]==’checkbox’)
    {
    $input_object[‘attributes’][‘checked’]=’checked’;
    }

    return $input_object;
    }
    add_filter(‘sf_input_object_pre’, ‘catcheck’, 10, 2);

    It does not work. In my various tests, I manage to act on the

      element that contains the input elements, but not on the input elements themselves.

      Thanks for your help.

      Olivier

    #52893

    Jose David Moliner
    Participant

    Thanks Ross!

    With this filter it’s possible to access to ‘heading’ label? I’ll need something like this:

    function filter_function_name($input_object, $sfid)
    {
    $input_object['heading'] = apply_filters( 'the_title', $input_object['heading'] );
    return $input_object;
    }
    add_filter('sf_input_object_pre', 'filter_function_name', 10, 2);
    #51817

    In reply to: Getting value from url


    Edward
    Participant

    Hello Trevor,
    This looks like a script that would work, I guess.
    How do I use this?

    function filter_function_name($input_object, $sfid)
    {
    	if($input_object['name']=='_my_field_name')
    	{
    		//udpate this field before rendering
    	}
    	
    	return $input_object;
    }
    add_filter('sf_input_object_pre', 'filter_function_name', 10, 2);
    #50568

    Jon Watson
    Participant

    Hey Davide!

    Sorry for the delay – hectic couple of weeks.

    Try this:

    // Relabel Co-Authors in Search & Filter
    
    	function filter_function_name($input_object, $sfid) {
    
    		if ($input_object['name'] == '_sft_author') {
    
    			global $coauthors_plus;
    			
    			// Update option labels before rendering
    
    				foreach($input_object['options'] as $key => $option) {
    
    					// Rename "all items" label - this is always the option with no value
    
    					if($option->value=="") {
    
    							$option->label = "All Authors";
    
    						}
    
    					else {
    
    						$user = $coauthors_plus->get_coauthor_by( 'user_nicename', $option->value );
    
    						$input_object['options'][$key]->label = $user->last_name . ', ' . $user->first_name . ' ' . ' (' . $option->count . ')';
    
    	    			}
    
    	        	}
    
    	        	$sortArray = array(); 
    
    	        	foreach($input_object['options'] as $option) { 
    
    				    foreach($option as $key => $value) { 
    
    				        if(!isset($sortArray[$key])) { 
    
    				            $sortArray[$key] = array(); 
    
    				        } 
    
    				        $sortArray[$key][] = $value; 
    
    				    }
    
    				}
    
    	        	$orderby = "label";
    
    				array_multisort($sortArray[$orderby],SORT_ASC,$input_object['options']); 
    
    		}
    		
    		// Return
    
    			return $input_object;
    
    	}
    
    	add_filter('sf_input_object_pre', 'filter_function_name', 10, 2);

    a
    Participant
    This reply has been marked as private.
Viewing 10 results - 131 through 140 (of 150 total)