Skip Navigation

[Resolved] Generating a post title from submitted form fields

This support ticket is created 2 years, 11 months 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

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

This topic contains 3 replies, has 2 voices.

Last updated by jennZ 2 years, 11 months ago.

Assisted by: Waqar.

Author
Posts
#2273217

I need to generate a custom post title based on custom fields submitted from a Toolset form. I've already referenced this post (https://toolset.com/forums/topic/post-link-from-custom-fields/) and modified it to fit my custom fields and such. It works for one custom post type, but not for another. There's no difference between the two that I can find (besides the different custom fields, of course), so I can't figure out why this is happening.

The code that works is:
//Create a dynamic post title by the CRED form for summits.
add_action('cred_save_data','func_custom_summit_post_title',10,2);
function func_custom_summit_post_title($post_id,$form_data) {
if ($form_data['id']==50611) {
$summit_title_directory = get_post_meta($post_id, 'wpcf-summit-title-directory', true);
$title= $summit_title_directory;
$args = array('ID' => $post_id, 'post_title' => $title);
wp_update_post($args);
}
}

and the code that doesn't work is:
//Create a dynamic post title by the CRED form for evergreen summits.
add_action('cred_save_data','func_custom_evergreen_summit_post_title',10,2);
function func_custom_evergreen_summit_post_title($post_id,$form_data) {
if ($form_data['id']==50671) {
$evergreentitle = get_post_meta($post_id, 'wpcf-evergreen-title', true);
$title= $evergreentitle;
$args = array('ID' => $post_id, 'post_title' => $title);
wp_update_post($args);
}
}

The form ID's match correctly. The field slugs match correctly. Am I missing something? I have two other dynamic post title functions that I haven't gotten to test yet, but now I'm worried they won't work either.

#2273849

Hi,

Thank you for contacting us and I'd be happy to assist.

To troubleshoot this, I'll need to see how both these forms are set up in the admin area.

Can you please share temporary admin login details, along with the link to the pages with these forms?

Note: Your next reply will be private and it is recommended to make a complete backup copy, before sharing the access details.

regards,
Waqar

#2275041

Thank you for sharing these details.

I tested the form "Evergreen Summit Submission Form" the code to update the custom fields value in the post's title, worked as expected.
( screenshot: hidden link )

Can you please check the form again and let me know how it goes?

#2275679

Huh, strange. It definitely didn't work before (it was blank for the title and slug), but I guess it sorted itself out!