caldera_forms_autopopulate_options_post_value_field

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

Description

apply_filters( 'caldera_forms_autopopulate_options_post_value_field', (string) $field_config_value_field, (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. $field_config_value_field (string)
What field to use for the value. Default is ID..
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. $field_config_value_field = apply_filters( 'caldera_forms_autopopulate_options_post_value_field', $field_config_value_field, $field, $form, $posts ); 
  2.  
  3. if ( !empty( $field_config_value_field ) ) { 
  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_value_field callback 
  2. function filter_caldera_forms_autopopulate_options_post_value_field( $field_config_value_field, $field, $form, $posts ) { 
  3. // make filter magic happen here... 
  4. return $field_config_value_field
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'caldera_forms_autopopulate_options_post_value_field', 'filter_caldera_forms_autopopulate_options_post_value_field', 10, 4 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'caldera_forms_autopopulate_options_post_value_field', 'filter_caldera_forms_autopopulate_options_post_value_field', 10, 4 ); 

Defined (1)

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

/classes/core.php  
  1. $field_for_value = apply_filters( 'caldera_forms_autopopulate_options_post_value_field', $field[ 'config' ][ 'value_field' ], $field, $form, $posts );