Skip Navigation

[Resolved] Setup post title from custom fields

This support ticket is created 3 years, 8 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 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by thomasK-12 3 years, 8 months ago.

Assisted by: Shane.

Author
Posts
#1744335

Tell us what you are trying to do?
I have setup a CPT called Obituaries, I am trying create a custom tittle for it, at the moment it comes in as something like 'CRED Auto Draft e427a60f5f5f6fb04c406d2345a5593f — Pending'. I would like it to be the First Name and the Last Name from the custom fields.

Is there any documentation that you are following?
I am following this documentation - https://toolset.com/forums/topic/post-link-from-custom-fields/
I have added this code to my child theme functions.php file;

//Create a dynamic post title by the CRED form.
add_action('cred_save_data','func_custom_post_title',10,2);
function func_custom_post_title($post_id,$form_data) {
if ($form_data['id']==357) {
$name = get_post_meta($post_id, 'first-name', true);
$lastname = get_post_meta($post_id, 'last-name', true);
$title= $name. '-' . $lastname;
$args = array('ID' => $post_id, 'post_title' => $title);
wp_update_post($args);
}
}

But now the Title is just ' - Pending'

Is there a similar example that we can see?
No

What is the link to your site?
hidden link

#1744619

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Thomas,

Thank you for getting in touch.

You may need to get the field values directly from the form. Can you send me a link tot he page where the form is so that I can have a look to determine what exactly are the slugs for the fields that you are retrieving ?

Thanks,
Shane

#1745313

Ah ha! I checked and in the front end it was 'wpcf-first-name' and 'wpcf-last-name'. So I updated the code and it worked.
My issue is resolved now. Thank you!

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