This plugin is heavily inspired by previous work by Justin Tadlock in explaining how WordPress actually support taxonomies for users and what additional code needs to be added to support this.
On the back of that Damian Gostomski wrote a plugin and added it too the repository to add said functionality. However the plugin was incomplete and development has stopped. As I am using this sort of functionality in the LocalHero project I have fixed some bugs in the original code and also added some new functionality so that when you use register_taxonomy to register a taxonomy for users you have almost as much control as if he taxonomy was for posts.
After numerous unsuccessful attempts to contact the plugin author to incorporate my enhancements I have forked the original plugin.
Fixes and enhancements to the original plugin include:
- Fixes a bug with display of existing user taxonomies in the user-edit screen
- Fixes a bug with taxonomy count in the old plugin where deleting users did not update the count
- Add support for ‘single_value’ attribute when registering a user taxonomy for taxonomies which should only have one value.
- Properly supports the capabilities associated with the taxonomy when registered.
- Supports ‘show_admin_column’ attribute when registering the taxonomy in the same way as post taxonomies.
- When ‘show_admin_column’ is set to true admins can bulk edit the user taxonomy.
Going forward will further enhance this plugin to incorporate the ‘hierarchical’ attribute used in registration when assigning a user taxonomy.
Questions
How do I get a user taxonomy to act like a category
Answer: By default user taxonomies are non hierarchical but if you need them to to have parent and child functionality then set ‘hierarchical’ => true, when regiustering and be sure to remove the single value restriction.
How do I get a user taxonomy to act like a post tag.
Answer: It does not support free form entry yet but i future releases this is planned.
January 27, 2016 at 3:01 am
Am I able to attach users to an existing custom post type taxonomy?
I want it to behave so when I add a new category to the custom post type, users are able to associate the updated category to their profiles via checkboxes.
May 3, 2016 at 5:43 pm
I think that’s pretty much what I’m advocating, too.
+2 for making post or custom post type taxonomies be the same as user taxonomies.
March 5, 2016 at 5:23 pm
Can I have a user taxonomy that uses the same taxonomy for post categories? (ie. where users are experts in the categories they write about).
March 19, 2016 at 6:51 am
How can I get the number of users that have a certain term ? Is it possible ?
Thanks for the plugin, it’s working perfect.
March 22, 2016 at 12:50 pm
Yenier,
thanks for the question
in the same way as for usual terms:
https://codex.wordpress.org/Function_Reference/get_term_by the results provides a count
May 24, 2016 at 12:49 am
Hi Peter, thanks for your answer. Another question. This can be pretty simple but how can I get the users of a certain taxonomy term ? I’m confused because WP_User_Query don’t have a taxonomy parameter. Can you explain the process ?
Regards
May 3, 2016 at 3:38 am
Any chance on linking up the Users count on the taxonomy page?
October 4, 2016 at 6:21 am
Hey. Love the Plugin, very useful. In using it, I realized the capabilities were not being respected (for example, to just show the taxonomy to the admin.)
I noticed line 197 of lh-user-taxonomies.php was commented out:
if(!current_user_can($taxonomy->cap->assign_terms)) continue;
When I undo the comment, it works as expected (for me anyway, using PHP 5.6.10 with WordPress 4.6.1). Just wanted to give you the heads up. Thanks for the plugin!
May 11, 2017 at 11:38 am
Hi! This was very helpful for a project I\’m working on. Much appreciated.
I did find a small issue. The single value property check in the plugin only checked for isset and not true/false. As a result one could not select multiple taxonomies for a single user without removing the property from the registration all together. I altered the plugin code as follows and it works like a champ.
Again…thank you!! Save me a bunch of time.
$input_type = ( isset($taxonomy->single_value) && $taxonomy->single_value == true ) ? \’radio\’ : \’checkbox\’ ;
June 30, 2018 at 4:05 am
Hello , i am having a hard time with LH User Taxonomies .
I use the single_value => false (checkbox)
when i empty all the checkboxes and update the user the last checked checkboxes are rechecked on the reload .
May 7, 2019 at 2:52 pm
This is fixed in the latest version
September 30, 2020 at 7:19 am
Hi Peter
Thanks for the plugin.
I am not seeing the user count updated for taxonomy terms when I delete a user. I’m using version 1.60. It looks like you fixed this from your post above.
Any advice greatly appreciated.
Regards
Mike
September 30, 2020 at 12:46 pm
No I have never added that functiionality. The above post is another issue. So you are correct when you delete a user the count will be wrong. However that count will update when you update another user so will fix itself.
I will look at adding that enahcement to the next version.
April 8, 2021 at 5:26 pm
Hello, thanks for this plugin. I have a question. My existing website use custom taxonomies (for custom post types ) created with ACF extended plugin. I would like to know if it possible to make these taxonomies available for users too. And users have custom roles .
April 8, 2021 at 6:03 pm
Ramin,
as it stands sharing a taxonomy across posts/pages/cpts and users can be done but will cause problems, see my answer here:
https://wordpress.org/plugins/lh-user-taxonomies/#can%20i%20set%20a%20taxonomy%20that%20includes%20posts%2Fpages%2Fcpt%C2%B4s%20with%20users%3F
It could be achieved by using shadow taxonomies but that would be custom work.
It may be possible in future versiobs of wordpress.
Pete