Skip Navigation

[Resolved] Content-submission + User-registration in one form.

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

Problem: I would like to use one Form to register a User and create a new post at the same time.

Solution: You can use generic fields and custom code in a new User Form to create a post at the same time. Combining both in one Form without custom code is not currently possible.

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/

This support ticket is created 6 years, 5 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
#918285

Tell us what you are trying to do?

I have a site where people can post an ad on the front end. That ad is a custom post type with custom fields. If people are not registered at my site i want to give them one form on the front end that will let them post an ad and register them to my site. Instead of register first at my site and then can post an ad.

Is there a similar example that we can see?

Yes it is possible with Gravity Forms. With the user registration add-on. You can make one form that will let the user post an ad and register at the same time. But Gravity forms doesn't load the custom fields that i made with toolset types in the custom post type. So i want to use CRED to do that. But i can not figure it out.

Hope you guys can help.

Regards, Guido

#918367

Hi, one Form can either create a new User, or create a new Post. The only way to do both in one Toolset Form is to use generic fields and custom code. Here is the general process:
- Create a New User registration Form as usual.
- Add generic fields to capture the new post's title and content, as well as any required custom fields for the post.
- Use the cred_save_data API to inspect the generic field values and insert a new post programmatically using the wp_insert_post API. In the cred_save_data callback, you will have access to the new User's ID, so you can set that new User as the author of the post.

If you have additional questions about this process, let me know. I can help with any Toolset-related code.

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/