Skip Navigation

[Resolved] Share taxonomy between CPT with users

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

Problem:

I wonder if there is a way I can merge both processes in a single step ie when user registers for user account, a profile is automatically created.

Solution:

One form can handle one post/user at the same time, in your case, you might consider custom shortcode, for example:

https://toolset.com/forums/topic/share-taxonomy-between-cpt-with-users/#post-1187923

Relevant Documentation:

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
- 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 4 replies, has 3 voices.

Last updated by deanL 5 years, 3 months ago.

Assisted by: Luo Yang.

Author
Posts
#1187275

I'm building a site that allows registered users to contribute stories, which are grouped by post categories (country names).

Under user profile, I would like to allow users to tag countries they have visited or planning to visit in future.

With that said, when visitors look at a country archive, they can see stories related to the country, as well as users who are interested in the countries.

I understand WordPress doesn't allow sharing of taxonomy between cpt and users. And I saw a suggestion from this forum, which is to create a cpt for user (eg Profile). While this sounds like a feasible plan, the problem I imagine will face next is, how do I control each registered user creates only one profile? Better still, to automatically create a profile each time someone register a new user account?

#1187333

Yes, that is correct, to create relationships or even just add Taxonomies to a User, you need to "convert" that user to a Post Type.
That's explained here:
https://toolset.com/documentation/post-relationships/how-to-create-custom-searches-and-relationships-for-users/
All doubts you mentioned are cleared in that DOC.

After, you can create an archive for the Countries (which is a taxonomy) and in there, include the User and Countries posts.

#1187620

Thank you Beda for the link to the doc. It does answer the question I had! I must really learn to search the Documentation section!

I haven't tried the solution yet, but I imagine the next challenge I may face, is to make it a more seamless process from creating user account to posting content. Because from the doc, user needs to create Contractor profile (second step) before he/she can proceed to create contractor post (ultimate objective).

I wonder if there is a way I can merge both processes in a single step ie when user registers for user account, a profile is automatically created. He/she may choose to fill in the additional details later, but he/she should be able to proceed to create post right after successful login. Will you advise?

#1187923

Hello,

For the question:

if there is a way I can merge both processes in a single step ie when user registers for user account, a profile is automatically created

No, there isn't such a built-in feature within Toolset form plugin, one form can handle one post/user at the same time, in your case, you might consider custom shortcode, for example, when user submits the registration form, use action hook cred_save_post to trigger a PHP function, in this function, create the new profile post.

More help:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
https://developer.wordpress.org/reference/functions/wp_insert_post/

#1188004

Thank you for answering my second question. I suddenly realized this may be taking too much of my time to implement and it will be out of scope. I will discuss with my client for alternative solution. But thank you anyway for your help so far!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.