You can filter your field parameters before they’re saved if you wish. In the example below, we’re setting a calculation field to be flat rate:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Filter our field params before they're saved | |
* In this case, set a calculation field with the ID 4991 to be flat rate | |
* @requires 3.4.3 and greater | |
*/ | |
function prefix_before_update_field_all_params( $all_params, $field_id ) { | |
if( $field_id == 4991 ) { | |
$all_params['field_flatrate'] = 1; | |
} | |
return $all_params; | |
} | |
add_filter( 'pewc_before_update_field_all_params', 'prefix_before_update_field_all_params', 10, 2 ); |