cmb2_save_<object_type>_fields_<cmb_id>

Fires after all fields have been saved.

Description

do_action( 'cmb2_save_<object_type>_fields_<cmb_id>', (int) $object_id, (string) $this_updated, (array) $instance ); 

The dynamic portion(s) of the hook name refer is the meta_box id.

The dynamic portion(s) of the hook name refer to the metabox/form's object type Could also be comment,, user. or options-page.

Parameters (3)

0. $object_id (int)
The ID of the current object
1. $this_updated (string)
Array of field ids that were updated. Will only include field ids that had values change.
2. $instance (array)
This CMB2 object

Usage

To run the hook, copy the example below.
  1. // run the action 
  2. do_action( 'cmb2_save_{$object_type}_fields_{$cmb_id}', $object_id, $this_updated, $instance ); 
The following example is for adding a hook callback.
  1. // define the cmb2_save_<object_type>_fields_<cmb_id> callback 
  2. function action_cmb2_save_object_type_fields_cmb_id( $object_id, $this_updated, $instance ) { 
  3. // make action magic happen here... 
  4. }; 
  5.  
  6. // add the action 
  7. add_action( "cmb2_save_{$object_type}_fields_{$cmb_id}", 'action_cmb2_save_object_type_fields_cmb_id', 10, 3 ); 
To remove a hook callback, use the example below.
  1. // remove the action 
  2. remove_action( "cmb2_save_{$object_type}_fields_{$cmb_id}", 'action_cmb2_save_object_type_fields_cmb_id', 10, 3 ); 

Defined (1)

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

/includes/CMB2.php  
  1. do_action( "cmb2_save_{$object_type}_fields_{$this->cmb_id}", $object_id, $this->updated, $this );