Skip Navigation

[Resolved] Get the title of post that is being created (not title of form location)

This support ticket is created 4 years, 1 month 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 2 replies, has 2 voices.

Last updated by andrei-laurentiuP 4 years, 1 month ago.

Assisted by: Nigel.

Author
Posts
#1812729

I have a custom post type that may be created from a form which is displayed on pages or other posts.

I would like to save the title of the new post that is being created in a variable that I use to log some events.

Is it possible to use somehow types_render_field(..); ?

get_the_title(..); -- seems to only return the title of the page / post where the form is located.

Any suggestion on how I could do this?

#1813415

Nigel
Supporter

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

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

You are using the Forms API, a hook such as cred_save_data to trigger your code?

If so then you have the post id of the created post available, see https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

So you can use get_post to retrieve the post object, and its title is then available as $post->post_title, see https://developer.wordpress.org/reference/functions/get_post/

#1813675

Sorry for the noob question. I was just trying to send a message when validating a post - wanted to record the post name and it can be easily done with $fields['post_title']['value']. My issue is resolved now. Thank you!