Skip Navigation

[Resolved] change post url "auto draft" to a specific custom field.

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

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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Tagged: 

This topic contains 1 reply, has 2 voices.

Last updated by Beda 8 years, 2 months ago.

Assisted by: Beda.

Author
Posts
#366193

hi
i have a cred form in which i'm not using the "post title" field. for these reason- all published posts have "auto-draft" in the url. for example: hidden link

is there a way to fix this? for example- that instead the "auto-draft4" it will be a date custom field?
something like that: hidden link

thank you 🙂

#366218

That's the way WordPress handles Posts when no Title/Name is provided.

Since you are using CRED, you will need to Custom Code a CRED API function that runs when you submit the Post from the front end.

The correct CRED API to use here is cred_save_data
https://toolset.com/documentation/user-guides/cred-api/#csd

In the Action (CRED API cred_save_data) you will use 2 WordPress API functions:

1. get_post_meta() for getting the Custom Fields value of the currently submitted post
https://developer.wordpress.org/reference/functions/get_post_meta/

2. wp_update_post() to update the Post Title with that value
https://codex.wordpress.org/Function_Reference/wp_update_post

A example Code to achieve this is visible here:
http://pastebin.com/2BTbVbcs

Please note the Types Custom Fields meta_key, it has always a "wpcf-"prefix

When you need to update the Post Title with a Types Date Field's value, you need another extra step.
Types Stores Date Fields as a DateStamp (UNIX)
That would create a "seconds from 0" amount-number and not a real date.

So you need to convert the TimeStamp to a WordPress Date Forms first.

For this you use the PHP function gmdate()
hidden link

Then you proceed as above.

A example code for this is here:
hidden link

Please let me know if you have further questions regarding the issue mentioned in this Thread
http://pastebin.com/A2UMXVUJ

Thank you for your patience.

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