Hi,
this didn't work for me either.
After digging deeper into the problem, I noticed that the saved values are retrieved from the RWMB_Request
object and that this is not updated after calling the 'before_save_post' action.
I have explicitly called the update of the Post values of the object calling the method set_post_data()
You could try and change your code as follows:
add_action( 'rwmb_m_contact_before_save_post', function() {
$_POST['add_new_contact'] = 0;
$_POST['test_field'] = 'test';
if ( function_exists( 'rwmb_request' ) ) {
rwmb_request()->set_post_data( $_POST );
}
} );
@justdoit123
Please, let me know if this corrects the problem on your side.
@Peter
Please, update the documentation or fix the problem, thanks.