caldera_forms_autopopulate_options_post_label_field

Filter which field is used for the LABEL when getting autopopulate option values when autopopulating options from post types.

Description

apply_filters( 'caldera_forms_autopopulate_options_post_label_field', (string) $post_title, (array) $field, (array) $form, (array) $posts ); 

Value can be any WP_Post field, or a meta key (be careful will return an empty string if that meta key isn't set for the post.

Parameters (4)

0. $post_title (string) => 'post_title'
What field to use for the label. Default is post_title..
1. $field (array)
Config for the field.
2. $form (array)
Config for the form.
3. $posts (array)
Current post collection.

Usage

To run the hook, copy the example below.
  1. $post_title = apply_filters( 'caldera_forms_autopopulate_options_post_label_field', $post_title, $field, $form, $posts ); 
  2.  
  3. if ( !empty( $post_title ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the caldera_forms_autopopulate_options_post_label_field callback 
  2. function filter_caldera_forms_autopopulate_options_post_label_field( $post_title, $field, $form, $posts ) { 
  3. // make filter magic happen here... 
  4. return $post_title
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'caldera_forms_autopopulate_options_post_label_field', 'filter_caldera_forms_autopopulate_options_post_label_field', 10, 4 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'caldera_forms_autopopulate_options_post_label_field', 'filter_caldera_forms_autopopulate_options_post_label_field', 10, 4 ); 

Defined (1)

The filter is defined in the following location(s).

/classes/core.php  
  1. $field_for_label = apply_filters( 'caldera_forms_autopopulate_options_post_label_field', 'post_title', $field, $form, $posts );