Data Being Saved On Error
-
At the moment whenever you submit the form and it errors out it will save the metadata to whatever the current post is. This means that the next user who visits the page will have pre-populated information from the previous user.
One possibly solution is to reset the Posted ACF values if it fires after WooCommerce saves that data. If you unset it you may run into index errors down the line by ACF:
/** * Reset the ACF Array before it saves postmeta * Priority 5 is Before Save, 10+ After Save * * @return void */ function acf_account_fields_save_prevention() { if( is_admin() || ! isset( $_POST['woocommerce-register-nonce'] ) || empty( $_POST['acf'] ) ) { return; } $_POST['acf'] = array(); } add_action( 'acf/save_post', 'acf_account_fields_save_prevention', 5 );
You may want to do some additional checks or pass something to the
$_POST
itself ( form an earlier action hook ) to ensure that it’s from the registration form with your ACF fields. Otherwise this could modify ACF saving that’s not expected to.– – – – – – – – –
Thanks for putting this plugin together! Other than a few things here and there it’s really solid
- The topic ‘Data Being Saved On Error’ is closed to new replies.