Hi! I have a custom post type that has three custom fields (account id, account number, account name) that each need to get updated by a select field whose options contain all three values combined together (and separated by a | character).
See the screenshot for a typical select option that contains the three values in the value attribute.
When the form is submitted, it triggers custom code that explodes the value into an array of three items, then uses update_post_meta, which is intended to update each of the three custom field values, like so:
add_action('cred_save_data', 'tssupp_auto_connect_to_parent_4',99,2);
function tssupp_auto_connect_to_parent_4($post_id, $form_data) {
if (in_array($form_data['id'], array( 30106 ))) { // Edit Aid Request (ID: 30106)
global $wpdb;
$account_params = $_POST['aid-account-array'];
$account_params_explode = explode('|', $account_params);
update_post_meta( $post_id, 'wpcf-account-name', $account_params_explode[2], true );
update_post_meta( $post_id, 'wpcf-aid-account-id', $account_params_explode[0], true );
update_post_meta( $post_id, 'wpcf-aid-account-number', $account_params_explode[1], true );
}
}
There's no error that I can see, but the fields in the custom post aren't getting updated.
One has to be logged in to see the work in progress (Minesh should have access to this site). One logged in, the edit form working on post id 40024 can be accessed via this URL:
hidden link
The Aid Account selection should be changed (other fields can be edited too, but it's the Aid Account we're concerned with).
When "Update" is pressed, you'll be redirected to hidden link, where one should see the new Account selected (but the change isn't being made).
The values for the Account ID, Account Number, and Account Name fields for post 40024 can be checked at hidden link
I assume my problem is in the custom code, but I'm not sure what I'm doing wrong.
Thanks for the assist,
David