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?
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?
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.
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".
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.