• Hi. Can you please update load_taxonomy_choices method in GFCPTAddonBase class.
    (i added filter in it)

    function load_taxonomy_choices($taxonomy, $type, $first_choice = '', $field ) {
    			$choices = array();
    
    			if ( in_array( $field->get_input_type(), gf_apply_filters( array( 'gfcpt_hierarchical_display', $field->formId, $field->fieldId ), array( 'select', 'multiselect' ) ) ) ) {
    
    				$terms = $this->load_taxonomy_hierarchical( $taxonomy, $field );
    
    				if( $field->get_input_type() == 'select' ) {
    					if ( $first_choice !== '' && $first_choice !== 'First Choice' && empty( $field->placeholder ) ) {
    						// if no default option is specified, dynamically create based on taxonomy name
    						$taxonomy = get_taxonomy($taxonomy);
    						$choices[] = array('text' => "-- select a {$taxonomy->labels->singular_name} --", 'value' => '');
    					}
    				}
    
    			} else {
    				$terms = get_terms($taxonomy, 'orderby=name&hide_empty=0');
    			}
    
    			if ( !array_key_exists("errors",$terms) ) {
    			  foreach($terms as $term) {
    				  $choices[] = array('value' => $term->term_id, 'text' => $term->name);
    			  }
    			}
    
    			return apply_filters( 'gfcptaddon_taxonomy_choices', $choices, $taxonomy, $type, $first_choice, $terms );
    		}
    

    I updated return in it to:

    return apply_filters( 'gfcptaddon_taxonomy_choices', $choices, $taxonomy, $type, $first_choice, $terms );

    Thanks.

    • This topic was modified 7 years, 3 months ago by AdSimple.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Add filter’ is closed to new replies.