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 🙂
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.