Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multisite taxonomies/terms for users #64

Open
schuhwerk opened this issue Feb 2, 2023 · 0 comments
Open

Multisite taxonomies/terms for users #64

schuhwerk opened this issue Feb 2, 2023 · 0 comments

Comments

@schuhwerk
Copy link
Contributor

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 affiliations live.
    • get_the_user's affiliations. Map them to the blog-affiliation's term id
    • Query the other taxonomy for the blog_ids
    • switch back
  • 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:
    $object_types = array( 'user', 'post' );
    register_multisite_taxonomy( $taxonomy_slug, $object_types, $args );
    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): wp_multisite_term_multisite_taxonomy could be used to create unique multisite_term_multisite_taxonomy_id s 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant