Skip Navigation

[Résolu] can I setup automatic transfer of information between custom fields

Ce fil est résolu. Voici une description du problème et la solution proposée.

Client wanted to auto-fill custom fields when a parent post (or a post) was saved - values taken based on the post. I suggested to use CRED API's cred_save_data() for CRED based forms, and WP's save_post() for actions from other places.

This support ticket is created Il y a 8 années et 8 mois. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 -
- - - - - - -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 2 réponses, has 2 voix.

Last updated by rodneyM Il y a 8 années et 8 mois.

Assisted by: Waqas.

Auteur
Publications
#325343

Is it possible to have an automatic transfer of information from one custom field to another custom field.

When I enter information into a custom field in a parent post type either in adding a new post or via a cred form can the information be automatically inserted into another custom field in the child post type.

The parent field and child field are both visible but rather than entering the information twice can it be done automatically.
Thanks

#325437

Waqas
Supporter

Languages: Anglais (English )

Timezone: Asia/Karachi (GMT+05:00)

For a CRED Form, you can use CRED API to do this when your form is submitted and data is saved, like below:

add_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($post_id, $form_data)
{
    // if a specific form
    if ($form_data['id']==12)
    {
        if (isset($_POST['my_custom_field']))
        {
            // add it to saved post meta
            add_post_meta($post_id, '__my_custom_field', $_POST['my_custom_field'], true);
        }
    }
}

You will need to add this to your theme's functions.php file and make adjustments accordingly. Please see https://toolset.com/documentation/user-guides/cred-api/#csd for more information.

For operations at other places, like creating a post in admin panel or via some other means, you can use WordPress save_post() action. Please see https://codex.wordpress.org/Plugin_API/Action_Reference/save_post for more information.

#325479

Thanks Waqas,
Once again you were very helpful.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.