Tell us what you are trying to do?
In an edit post form I would like to save a value from a dynamic select field into another field for display and storage purposes.
Is there any documentation that you are following?
I searched for a similar approach but could not find any documentation or help for this.
Is there a similar example that we can see?
Yes there are forms in place needing the change.
What is the link to your site?
Need to provide credentials as no public access at the moment!
To elaborate further in the edit post form I have a country look-up select field from a third-party solution. I will need that value selected to be saved into the database. And then retrieved for display in the listings view. Please see the attached screenshot.
The idea here is that I could maybe use a second field into which I copy the selected value and upon saving the form can be retrieved.
add_action('cred_save_data', 'func_update_contry_field',10,2);
function func_update_contry_field($post_id, $form_data){
// if a specific form
if ($form_data['id']==9999){
if (isset($_POST['field-slug-current-country']))
{
// add it to saved post meta
update_post_meta($post_id, 'filed-slug-to-store-country', $_POST['field-slug-current-country']);
}
}
Where:
- Please replace 9999 with your original form ID
- replace the correct field slugs with "field-slug-current-country" and "filed-slug-to-store-country"