cmb2_render_<fieldtype>

Pass non-existent field types through an action.

Description

do_action( 'cmb2_render_<fieldtype>', (array) $this_field, (mixed) $this_field_escaped_value, (int) $this_field_object_id, (string) $this_field_object_type, (object) $instance ); 

The dynamic portion(s) of the hook name refer to the field type.

Parameters (5)

0. $this_field (array)
The passed in CMB2_Field object
1. $this_field_escaped_value (mixed)
The value of this field escaped. It defaults to sanitize_text_field.. If you need the unescaped value, you can access it via $field->value()
2. $this_field_object_id (int)
The ID of the current object
3. $this_field_object_type (string)
The type of object you are working with. Most commonly, post (this applies to all post-types), but could also be comment,, user. or options-page.
4. $instance (object)
This CMB2_Types object

Usage

To run the hook, copy the example below.
  1. // run the action 
  2. do_action( 'cmb2_render_{$fieldtype}', $this_field, $this_field_escaped_value, $this_field_object_id, $this_field_object_type, $instance ); 
The following example is for adding a hook callback.
  1. // define the cmb2_render_<fieldtype> callback 
  2. function action_cmb2_render_fieldtype( $this_field, $this_field_escaped_value, $this_field_object_id, $this_field_object_type, $instance ) { 
  3. // make action magic happen here... 
  4. }; 
  5.  
  6. // add the action 
  7. add_action( "cmb2_render_{$fieldtype}", 'action_cmb2_render_fieldtype', 10, 5 ); 
To remove a hook callback, use the example below.
  1. // remove the action 
  2. remove_action( "cmb2_render_{$fieldtype}", 'action_cmb2_render_fieldtype', 10, 5 ); 

Defined (1)

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

/includes/CMB2_Types.php  
  1. do_action( "cmb2_render_{$fieldtype}", $this->field, $this->field->escaped_value(), $this->field->object_id, $this->field->object_type, $this );