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.