Skip Navigation

[Resolved] How to combine a user form with a post form in one submit?

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to create a new User and create a new Post by submitting one Form.

Solution: This will require custom code.
- Create a New User Form that includes all the User field information you want to capture for registration.
- Insert generic fields to capture each of the Party fields.
- Add some custom code with the Forms API cred_save_data to collect the information from the generic fields, and store that information by programmatically creating a Party post. You can set the new User as the Party post author to connect the User and the new Party.

Relevant Documentation:
https://toolset.com/documentation/user-guides/inserting-generic-fields-into-forms/
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
https://developer.wordpress.org/reference/functions/wp_insert_post/
https://toolset.com/forums/topic/auto-create-custom-post-after-new-user-submission/

This support ticket is created 5 years, 3 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Author
Posts
#1336455

I want to register a new user. They have to fill in the traditional user stuff via Toolset Forms:

- Firstname
- Lastname
- Email address
- ...

Before they submit the form, they also should fill in some other fields. Those fields are related to my custom post type called 'parties'. A user can have multiple parties, a party is linked to only one user.

Those are a couple of fields they should fill in next to the user stuff:

- Party name
- Date
- Organizer
- Type
- ...

Is there a way to integrate those two forms on one page and save both form data with just one submit button?

#1337015

Hello, a single Form can be configured to create or edit one Post, or create or edit one User...but not both at the same time. If you want to register a new User and create a post in one Form, it will require custom code with PHP and the Forms API. Generally, these are the steps:

- Create a New User Form that includes all the User field information you want to capture for registration.

- Insert generic fields to capture each of the Party fields: https://toolset.com/documentation/user-guides/inserting-generic-fields-into-forms/

- Add some custom code with the Forms API cred_save_data to collect the information from the generic fields, and store that information by programmatically creating a Party post. You can set the new User as the Party post author to connect the User and the new Party. We have documentation about the cred_save_data API available here: https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
...and information about creating a post programmatically on the WordPress site: https://developer.wordpress.org/reference/functions/wp_insert_post/

I helped on another ticket here you may find useful: https://toolset.com/forums/topic/auto-create-custom-post-after-new-user-submission/

I'm not sure of your skill level with PHP, so this is just a basic overview. Let me know if you have questions about this process and I can offer more guidance.

#1339455

My issue is resolved now. Thank you!