If you haven’t gotten the answer to this yet, I found the answer by sifting through the source code. I was able to hook into the post save event by using: cmb2_save_{$object_type}_fields_{$cmb_id}
. This hook fires whenever you save a certain object type with a specific metabox ID.
So, in your case your $cmb_id
is test_metabox
, and $object_type
will be page
.
Hooking in would look something like this:
add_action( 'cmb2_save_page_fields_test_metabox', 'my_post_save_function', 10, 3 );
function my_post_save_function( string $object_id, array $updated, CMB2 $cmb )
{
// code
}
The docblock in the source is messed up, I corrected the parameter types above: Source