Skip Navigation

[Resolved] Build a combined form for User Registration and Post Submission

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.

Author
Posts
#1994121

Tell us what you are trying to do?

-> I would like to build a post submission form and register the user at the time of submission. I would like to achieve my goal without manually coding as I do not have any experience with PHP.

Is there any documentation that you are following?

-> Yes. https://toolset.com/forums/topic/how-to-combine-a-user-form-with-a-post-form-in-one-submit/

I know how to create a basic user register form. I know how to add generic field. But I DO NOT understand anything about coding, CRED API, creating code programmatically as state on the following steps:

" - 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/ "

Is there a similar example that we can see?
-> This is a very common thing in user generated post websites. Usually we want to register user at the time of posting to simplify the process. There are several form plugins that provide this service as Buddyforms and WPForms, but I would like to use you because of the searching capability you provide. Please help me with a simple solution as I'm not a professional developer.

What is the link to your site?
-> Br2you.net

#1994281

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Hello and thank you for contacting the Toolset support.

Currently, a Toolset form can create or edit ONLY ONE item. Post forms can create/edit ONE post, and User forms can create/edit ONE user. If you want to combine user creation and post creation on the same form, you will need custom PHP code. And if you are not comfortable with programming, you should hire a developer. This is a list of our partners https://toolset.com/contractors/

On the other hand, you can allow users to register then create a post without needing any custom post. But, you will need two forms, one for the user registration, and the other one for creating posts. The first form can be configured to redirect the user to the post form. So, it will be two steps process.

If you have simple case, that won't need too much customization, we can help you build the needed custom code, but if your use case has several/multiple/complex requirements, you should consider hiring a developer.

#1994647

Thanks for the quick response Jamal.

I have a question considering the option of using two separate forms. If a user goes through a registration process first, will the user be automatically logged in and ready to create posts? or they also need to go through a login form in order to post? I'm point out the login step because it is crucial to have a post link to the author so it can be edit later on if needed.

For the later option, I believe my case is quite simple. I have already built the post form. All I would need now is to include a User Name and Password field to the form so I can register the user at the time of post submission. My goal is to create a user and link it the post at the time of submission, if possible. This way users would only login if they need to edit their post or change their profile.

Can you please clarify these two scenarios please?

Thank you again!

#1995749

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Actually, the user registration form will not log in to the user automatically. The user needs to login, and then he can submit posts where he is the author to be able to edit them later. It will need a custom code to automatically log in the user. Check this previous ticket https://toolset.com/forums/topic/automatically-log-in-user-after-created/#post-621650

Here an example of custom code that creates a user after post submission: https://toolset.com/forums/topic/automatically-log-in-user-after-created/#post-621650
Please note that this code does not set the created user as the author of the post.

Here an example of creating a new post upon user registration https://toolset.com/forums/topic/form-to-create-new-user-and-cpt-item/#post-1285741