Skip Navigation

[Resolved] Taxonomy to wp users and view filter

This support ticket is created 7 years 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.

Our next available supporter will start replying to tickets in about 5.91 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 3 replies, has 2 voices.

Last updated by tiagoS-3 7 years ago.

Assisted by: Nigel.

Author
Posts
#588310

Question 1 - What's the best way to associate a taxonomy to wp users?
Question 2 - How can filter the view by this user taxonomy?

What I need to do:
- I have a CPT named "Item"
- "Items" have a taxonomy named "Topic"
- Users can choose tags in "Topic" (question 1)
- A view shows Items, filtered by tags/Topic for that logged user (question 2)

#588486

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Tiago

In WordPress taxonomies apply to posts only, not to users. You can find plugins that will add this functionality (e.g. https://wordpress.org/plugins/lh-user-taxonomies/) but it requires you to manually register the taxonomies and you shouldn't expect that it will work with Views queries, you would need a custom solution for that, too. Custom queries only work for posts with Views.

If the idea is that every user stores their own tag preferences to match up with the tags of the items you could try making a User Preferences post type that is a child type of Items where the user is the author of the User Preferences post and so each user can tag this User Preferences post differently, and they are connected to the parent Item post.

To view Items with the tags stored in the User Preferences post type for that user you would then use nested Views.

The outer View would return the User Preferences post for the current user, and in the Loop Output section of that View you would insert a second View which returned the Item posts and used a taxonomy filter where the tag terms were set by the current post.

I'll leave the details up to you, but that is how I would attempt it using Toolset.

Let me know how you get on and if you get stuck on any particular part.

#588781

Nice Nigel! Work perfectly.

Question 1 - Create a new CPT to intermediate ("Users Preferences" in this case).
Question 2 - Use view inside view.

Using this solution I have two questions. I'll use another forum post to close that (https://toolset.com/forums/topic/limit-users-to-create-only-1-post-type-create-new-user-and-new-post/)

Thanks for the support.

#588877

[Resolved]