I have a front end form on this page: https://kambriaevans.com/intensive-directory-submissions/
For the option fields Modalities Used and Populations Served I want to show the option Other but I want it to save as Other - See below for more info.
On submit it creates a new post type called 'intensive-directory'
I don't have issues changing the data on text fields, but the array is giving some issues.
Here's what I have atm, but not working. I assume I'm not getting the array correctly (Only for Modalities Used field)
function modify_modalities_used_field($data, $postarr) {
// Check the post type to ensure it's for 'intensive-directory'
if ($data['post_type'] === 'intensive-directory') {
// Check if the custom field 'modalities_used' exists in the submitted data
if (isset($postarr['meta_input']['modalities_used']) && $postarr['meta_input']['modalities_used'] === 'other') {
// Change the value to 'Other - See below for more info'
$postarr['meta_input']['modalities_used'] = 'Other - See below for more info';
}
}
return $data;
}
add_filter('wp_insert_post_data', 'modify_modalities_used_field', 10, 2);