We now have a new after_save_field
referenced in this post that has access to all the meta field attributes, new and old meta values. The problem I am having is that this filter is triggered after the field is saved. So any values that need to be adjusted (or not saved at all) have already been submitted to the database.
Is there a way to include a before_save_field filter that would provide the same access (all field meta, including custom attributes, new and old values)?
I have currently done a test:
RWMB_Field::filter( 'before_save_field', null, $field, $new, $old, $post_id, $field );
// Call defined method to save meta value, if there's no methods, call common one.
RWMB_Field::call( $field, 'save', $new, $old, $post_id );
RWMB_Field::filter( 'after_save_field', null, $field, $new, $old, $post_id, $field );
And then added the following to my class:
add_action( 'rwmb_after_save_field', array( $this, 'pi_moderated_save' ), 10, 5 );
function pi_moderated_save ( $null, $field, $new, $old, $post_id ) {
if($field['id'] == 'truthiness' && !empty( $field['attributes']['mod_lock'] ) ){
$new = '';
}
}
But the $new variable is not being filtered.
I have tried using add_filter instead of add_action and also return $new; with no success.