cmb2_override_meta_value

Filter whether to override getting of meta value.

Description

apply_filters( 'cmb2_override_meta_value', (string) $cmb2_field_no_override_val, (int) $this_object_id, (array) $a, (CMB2_Field) $instance ); 

Returning a non cmb2_field_no_override_val value will effectively short-circuit the value retrieval.

Parameters (4)

0. $cmb2_field_no_override_val (string) => 'cmb2_field_no_override_val'
The value get_metadata() should return - a single metadata value, or an array of values.
1. $this_object_id (int)
The this object id.
2. $a (array)
3. $instance (CMB2_Field)
Object $field This field object

Usage

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

Defined (1)

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

/includes/CMB2_Field.php  
  1. $data = apply_filters( 'cmb2_override_meta_value', 'cmb2_field_no_override_val', $this->object_id, $a, $this );