Skip Navigation

[Resolved] Passing a value from a cred form to another field

This support ticket is created 7 years ago. 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.

Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 13:00 8:00 – 13:00 8:00 – 13:00 8:00 – 13:00 8:00 – 13:00 -
- 14:00 – 17:00 14:00 – 17:00 14:00 – 17:00 14:00 – 17:00 14:00 – 17:00 -

Supporter timezone: Indian/Mauritius (GMT+04:00)

This topic contains 5 replies, has 2 voices.

Last updated by Arvish Mungur 7 years ago.

Assisted by: Arvish Mungur.

Author
Posts
#512376

I am trying to pass a value from a CRED form to another field when the user clicks on "submit." Specifically I am trying to pass the url of an embedded video to another custom field when submitting the form via a function. I want the function to work so that users can edit/update the url of the embedded video if they need to in the future and it still pass the value into that other custom field.

Any suggestions?

#512560

Hello davidT-17,

Thank you for contact Toolset Support.

I will be happy to help you with your issue.

From your explanation, I am unsure as to how you are trying to pass on the url of the embedded video.

Could you please clarify the following to allow me to understand the issue correctly:

Where is this url coming from? Another input field or somewhere else on the page?
Is this value then saved on the same form in another field or on a different form/page?

A link to the site/page, your current code and screenshots explaining the flow would be extremely helpful in helping us formulate a solution.

Additionally, if required, you can also refer to the CRED API, more specifically to the following hooks cred_save_data and cred_before_save_data to process and save the custom field.

https://toolset.com/documentation/programmer-reference/cred-api

Awaiting your reply.

Kind regards

#516096
PC-Project-Screenshot-Embed-1.jpg
PC-Project-Screenshot-Embed-4.jpg
PC-Project-Screenshot-Embed-3.jpg
PC-Project-Screenshot-Embed-2.jpg

Thank you Arvish for your help with this.

I have attached some screenshots of where the url is embedded and the metabox we ultimately want the url passed to when saving the form data. We are trying to get a featured image generated from the videos that are embedded so that users have a visual representation of the custom post type when looking at the views.

#516367

Hello davidT-17,

Thank you for your reply.

You could use the ‘cred_save_data’ hook to save the another post meta value with one of the form’s values as follows:

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']==YOUR_FORM_ID)
    {
        if (isset($_POST['my_video_link_field']))
        {
            // add it to saved post meta
            add_post_meta($post_id, '__my_video_other_link_field', $_POST['my_video_link_field'], true);
        }
    }
}

Don’t forget to replace ‘YOUR_FORM_ID’ with your CRED form’s ID.

hidden link

Please let me know if this helps.

Kind regards

#517559

Thank you Arvish. Giving it a try right now.

#517687

Hello davidT-17,

Thank you for your reply.

Let me know if the solution works for me to consider the issue as resolved or if you need further assistance.

Kind regards

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