Tell us what you are trying to do?
I am using a Post Form so that users can create new posts. The created Post has a long string as the title: "CRED Auto Draft 60f087e2776348fa19faa722d34dbe92". How do I change this so the the post has the title based on "[types field='name'][/types]"?
Is there any documentation that you are following?
The Toolset videos
Based on what i see here you have removed the default post title field from your form.
To set the post title based on custom fields you will need to use some amount of custom code. Here is an example code below that allows you to do it. Add the following to your Toolset custom code settings at Toolset->Settings->Custom Code. Once you've done this please ensure that you've activated it as well as change the ID to the ID of your form.
function ttd_save_data_action($post_id, $form_data){
// Change your CRED Form "ID" accordingly below
if ($form_data['id']==ID){
//Declare the content of your variables, change "your_custom_field_slug" accordingly
$custom_title = get_post_meta( $post_id, 'wpcf-your_custom_field_slug', true );//get posts' field value
//collect data and define new title
$my_post = array(
'ID' => $post_id,
'post_title' => $custom_title,
'post_name' => $custom_title,
);
// Update the post into the database
wp_update_post( $my_post );
}
}
add_action('cred_save_data', 'ttd_save_data_action',10,2);
Hi, thanks for the reply. OK, you are right I removed the Title element in my form. Putting it back solves the issue. The problem is that the "Name" element is locked and required on the form and I don't want the user to have to enter their name twice.
That would be because you have created a name custom field and set it as required. The form inherits the requirement that it is required.
Change the settings for the custom field so that it's not required. Or you can switch your form to expert mode, where you'll see the markup and shortcodes it is comprised of, and you can simply delete the part that adds the name field.
The topic ‘[Closed] How do I change the post title created by Post Form?’ is closed to new replies.