Skip Navigation

[Resolved] Create user and custom post at the same time

This support ticket is created 2 years, 1 month 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 5 replies, has 2 voices.

Last updated by Miguel 2 years ago.

Assisted by: Luo Yang.

Author
Posts
#2531045

Tell us what you are trying to do?
I am developing a system for managing student enrollments in different courses.

I have read these: https://toolset.com/course-lesson/how-to-create-custom-searches-and-relationships-for-users/

But it is not exactly what I want to do, since in the example the user must first register to later access and publish content.

What I want is that, through a course registration form, create the user at the same time, storing both the user data and the course to which they have registered.

I started by adding custom fields in User Fields, but then I realized that I can't relate the user I create in WordPress to a custom post.

How could I solve it?

Is there any documentation that you are following?
I have read these: https://toolset.com/course-lesson/how-to-create-custom-searches-and-relationships-for-users/
https://toolset.com/forums/topic/relationship-between-custom-posts-and-users/

Is there a similar example that we can see?
Any web of courses where you can subscribe to

What is the link to your site?
its a local site.

#2531731

Hello,

There isn't such kind of built-in feature within Toolset Forms plugin.

One user form can handle only one user by default, in your case, you might consider custom codes, for example:
After user registered with the user form, use action hook "cred_save_data" to trigger a custom PHP function:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
And in this PHP function, create the new post with PHP function wp_insert_post()

See the custom codes of below tip:
hidden link

#2531833

Luo, your ideas sound great.

I will try!

thank you!

#2531853

Lou, I tried the custom PHP function and it worked!

But... I have two new questions:
1- In the user registration form there are 2 different fields that I don't understand: username and nickname. What is the difference between them?

2- When I enter a username that already exists, it doesn't send the form and it doesn't notify that the username already exists. Is there any way to validate it?

New threads created by Luo Yang and linked to this one are listed below:

https://toolset.com/forums/topic/i-have-two-new-questions/

#2532505

According to our support policy, we prefer one ticket one question, I assume the original question of this thread is resolved.
For the other new questions, please check the new ticket here:
https://toolset.com/forums/topic/i-have-two-new-questions/

#2532893

My issue is resolved now. Thank you!