Skip Navigation

[Resolved] Auto-populate title

This support ticket is created 7 years, 1 month 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.

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
- 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 3 replies, has 2 voices.

Last updated by stewartE 7 years, 1 month ago.

Assisted by: Shane.

Author
Posts
#573219

Hi, I was wondering if it is possible to hide the post title in a cred form and have it auto-populate with the post-id when the form is submitted?

It doesn't make sense for the user to fill in a title, but I do need to be able to uniquely identify each completed post (i.e by post id)

I am using a custom post type with custom fields added to it and then a CRED form on the front end for my users to create the custom post.

Thanks!

#573289

Shane
Supporter

Languages: English (English )

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

Hi Stewart,

Thank you for contacting our support forum.

Could you try using this example as a base to do your custom title.

//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']==9999) {
        $name = get_post_meta($post_id, 'wpcf-name', true);
        $email = get_post_meta($post_id, 'wpcf-email', true);
        $title= $name. '-' . $email;
        $args = array('ID' => $post_id, 'post_title' => $title);
        wp_update_post($args);
    }
}

Add it to your functions.php file and let me know if this helps.

Thanks,
Shane

#573308
shouldbe.PNG
saved.PNG
Capture.PNG
auto.PNG

Hi Shane I don't think that has quite worked. On the front end, it said post saved. But when I look at the post list it has saved it as autodraft with a long string of numbers, instead of the post id. When I look in the source code the post id=43

I would expect the post title to be 43

Thanks!

#573319

Hi Shane - just realized there is another way I can go about this that might be simpler. Going to rename the Post TItle label on the front end. They have to add a purchase order number so ill get them to fill that in here and add the post id using the post id shortcode. I think that will work!