Problem:
Get the ID of a youtube video and display it with a shortcode inside of a content template and store it in a another custom post field created with types to turn the ID into a shortcode then display on the page.
Solution:
You can do it using cred_save_data hook something 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_video_field'])) { $link = $_POST['my_custom_video_field']; $video_id = explode("?v=", $link); // For videos like <em><u>hidden link</u></em>... if (empty($video_id[1])) $video_id = explode("/v/", $link); // For videos like <em><u>hidden link</u></em>.. $video_id = explode("&", $video_id[1]); // Deleting any other params $video_id = $video_id[0]; // here is your required video ID // add it to saved post meta add_post_meta($post_id, '__my_custom_video_field', $video_id, true); } } }
==> Please replace '12' to your CRED form ID in the above code.
==> Replace 'my_custom_video_field' to your field slug
==> Replace '__my_custom_video_field' to your field slug where we need to save youtube ID.
Relevant Documentation:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
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 |
---|---|---|---|---|---|---|
- | 12:00 – 17:00 | 12:00 – 17:00 | 12:00 – 17:00 | 12:00 – 17:00 | 12:00 – 17:00 | - |
- | 18:00 – 21:00 | 18:00 – 21:00 | 18:00 – 21:00 | 18:00 – 21:00 | 18:00 – 21:00 | - |
Supporter timezone: Asia/Karachi (GMT+05:00)