Skip Navigation

[Resolved] Using Forminator to register a user and create a post in my custom post type

This support ticket is created 2 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 4 replies, has 3 voices.

Last updated by sianE 2 years, 9 months ago.

Assisted by: Minesh.

Author
Posts
#2349305

Tell us what you are trying to do?

I am trying to use Forminator (plugin) to create a form that will register a new user (this works fine) and create a post in my custom post type. I think I can achieve this using API but I have no idea where to start and would like to know if it is even possible to do this... and if possible could I have some guidance.

Is there any documentation that you are following?

https://toolset.com/lesson-placement/lesson-placements-1645361-1622635/
https://toolset.com/documentation/programmer-reference/cred-api/
https://toolset.com/documentation/programmer-reference/toolset-hooks/
hidden link
hidden link

#2349333

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Do you mean that you want to drop the use of plugin Forminator and instead you want to use the Toolset forms plugin to register the new users as well as to create a new post after successful creation of user?

#2349335

Nigel
Supporter

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

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

Hi there

As you are using Forminator the Toolset APIs are rather irrelevant.

I had a quick look at the link to the Forminator API docs, where I can see it lists lots of API methods (functions) you can call, but what I don't see listed there are any hooks tied to the form submission.

What you need is a hook that is triggered when the form has been submitted and processed, which you can then use to run your code that creates the post.

When you register custom post types with Toolset, that is really just a user-friendly UI for the WordPress register_post_type function (https://developer.wordpress.org/reference/functions/register_post_type/), i.e. a post type created using Toolset is exactly the same as a post type created with WordPress. So your code will be using native WordPress functions such as wp_insert_post (https://developer.wordpress.org/reference/functions/wp_insert_post/) to publish your custom posts.

So you really need to check with the Forminator support team about the availability of a hook when the form submission has been handled, and—because you are just using native WordPress functions like wp_insert_post—they should be able to point you towards an example of using it to publish a post.

Toolset doesn't have an API for publishing custom fields (only for displaying formatted fields), and so you will also be using native WordPress functions to add custom fields to your posts (e.g. add_post_meta: https://developer.wordpress.org/reference/functions/add_post_meta/), where the one thing you need to be aware of is when you register a custom field with some slug, e.g. "priority", it is stored in wp_postmeta with a meta key that includes a "wpcf-" prefix, e.g. "wpcf-priority".

#2349361

My issue is resolved now. Thank you!

#2349363

Hi there,

I realised that I didn't need the API - I forgot about the wpcf- prefix, which worked in Forminators native post data form settings! Yay!

Now my only issue is where I have to use a normal post field (e.g. Post title) in order to submit this info.

With Toolset forms, I could use the cred save data to make name custom field save as the post title. However, with Forminator, I have to figure out now how to make the post title field save as the name custom field. I suppose I will have to bring with up with them now.

Thanks Nigel!