-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Hello! Me again. Thanks for your work! 👋
Tldr.: Are you interested integrating user- and blog-terms (assigning multisite-terms not only to posts, but to sites and users)? You can find the implementation for users here.
And the longer version:
I was working on adding multisite-taxonomies to network-users for the last few days:
$taxonomy_slug = 'job';
$object_type = 'user';
register_multisite_taxonomy( $taxonomy_slug, $object_type, $args );The taxonomy-selectbox appears on the profile-page of a user.
Everything works the same as before for other taxonomies.
But why?
We are a big university (with ~20k people) which is grouped into many faculties, wich are subgrouped into organisations, and sub-communities (of students and teachers).
Imagine a big category-tree-structure (with ~300 entries), let's call them affiliations.
We want to assign those terms to users, blogs and also posts and make the right blogs/posts visible/filterable for the right group of people.
Why not use regular WordPress taxonomies?
We use the same tree of taxonomies three times: for users, blogs, and posts.
I wrote a library to sync terms between taxonomies (and everything is working fine), but it is not a pleasure to work with:
- "Show all blogs, which are assigned to the current user's faculty". This requires you to:
- switch to the blog, where your
affiliationslive. - get_the_user's
affiliations. Map them to the blog-affiliation's term id - Query the other taxonomy for the blog_ids
- switch back
- switch to the blog, where your
- Managing terms/taxonomies, which affect the whole network should not live in a blog (but in the network-admin).
- The WordPress structure for taxonomies is quite smart and flexible, but it can not be used to share terms between different object-types (unless you are willing to support your own WordPress fork). Multisite-taxonomies looks like a perfect place to start.
Issues
- When I assign a term to a user, the blog_id is also assigned, which does not make sense in my use-case. This could lead to confusion (or be nice in other use-cases).
- Same for blogs.
- There is currently no page when clicking on the number below "Count" in the network-taxonomy-admin interface ![[Pasted image 20230202142810.png]]
- ID-collisions:
If you assign multiple object_types (that do not have unique ids) to a taxonomy you will not be able to distinguish, if a term has been assigned to the user with the id "1" or the post with the id "1". So I disabled it (for now). Looking ahead (not part of this issue/question):
$object_types = array( 'user', 'post' ); register_multisite_taxonomy( $taxonomy_slug, $object_types, $args );
wp_multisite_term_multisite_taxonomycould be used to create uniquemultisite_term_multisite_taxonomy_ids for (non-post) object_types.
Chances
- Central role/capability management (just add a multisite_term_meta with capabilities to a user_multisite_term)
- Multisite-categories for blogs.
- Longer-term (also looking ahead): Assign (multiple) terms to terms 🤯
What do you think? - Should I create a PR? - Or should it just live in our fork?
Thanks for your time!