Skip Navigation

[Closed] How do I change the post title created by Post Form?

This support ticket is created 2 years, 3 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)

Tagged: 

This topic contains 3 replies, has 3 voices.

Last updated by Nigel 2 years, 3 months ago.

Assisted by: Waqar.

Author
Posts
#2463799
Screen Shot 2022-09-23 at 11.53.00 AM.png

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

#2463849

Shane
Supporter

Languages: English (English )

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

Hi Joel,

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);

Please let me know if this helps.
Thanks,
Shane

#2464153

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.

#2467053

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

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.