Skip Navigation

[Closed] Settings for Title of Post created from Post Form

This support ticket is created 3 years, 9 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: Africa/Casablanca (GMT+00:00)

This topic contains 4 replies, has 2 voices.

Last updated by Jamal 3 years, 8 months ago.

Assisted by: Jamal.

Author
Posts
#1710747
Ekran Resmi 2020-07-18 02.56.03.png

Hi

I want to set proper title for automatically created by users through post form. If it's possible I'd like to use some field info from the post form.

I checked this topic but I couldn't handle anyway.
https://toolset.com/forums/topic/saving-user-first-name-last-name-as-post-title-post-date-time/
I tried to copy code on the top this page and add to my site specific plugin but it isn't working, no signal to chase.

Can you help me?

Kutay

#1711089

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Hello Kutay and thank you for contacting the Toolset support.

Can you share the code that you are using? Or allow me temporary access to your website to check it closely?
Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **

#1716393

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Thank you for the credentials.

I believe you are talking about this custom code, right? Please let me know if you are talking about another code?

function md_checkout_title( $post_id ) {
  if( 'material-check-out' == get_post_type($post_id) ) {
    remove_action( 'save_post', 'md_checkout_title' );
    $date = date( 'Y-m-d H:i:s', time() );
    $author_id = get_post_field( 'post_author', $post_id );
    $first_name = get_the_author_meta( 'first_name', $author_id );
    $updated_data = array(
      'ID' => $post_id,
      'post_title' => $first_name . $date
    );
    wp_update_post( $updated_data );
    add_action( 'save_post', 'md_checkout_title' );
  } else {
    return;
  }
}
add_action( 'save_post', 'md_checkout_title' );

If this is the case, you will need to update the code to suit your use case.
- Change "material-check-out" on line 2 with your custom post type.
- Change lines 4-11 to suits your logic to build title.

How would you like to build your automatic title?

#1716683

Thanks a lot. This works but I might have further related questions. I don't want to mess the support center, that's why would you mind If I ask that you not to close this ticket for a while.

#1717079

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Of course! I am setting this ticket as waiting for your response. It should be kept open for 3 weeks.
Feel free to open a new ticket for any other question or issue.

The topic ‘[Closed] Settings for Title of Post created from Post Form’ is closed to new replies.