Skip to content

1.0.0

Choose a tag to compare

@davefx davefx released this 30 Jul 03:15
· 11 commits to main since this release

First release, extracted from LeanRoles.

A user tag behaves like a role to the whole of WordPress — it appears in $user->roles, answers current_user_can(), and WP_User_Query finds it — while granting no capability and never being written to the autoloaded {prefix}user_roles option.

WordPress offers no primitive for this user is a wholesale customer without granting them permissions. There are only roles, which is why membership and commerce plugins keep inventing them. This is the alternative, and it is free for any plugin to bundle.

Install

git subtree add --prefix libraries/user-tags \
    https://github.com/davefx/user-tags.git main --squash

Then one line in your plugin: require_once __DIR__ . '/libraries/user-tags/user-tags.php';

Shaped around the problems Action Scheduler accumulated

  • No custom tables, so no schema version and no migrations.
  • The version registry is frozen and keeps its state in a global, so a future one can read what an older one collected.
  • A copy registering late does not lock out a newer sibling.
  • Feature detection by name (user_tags_supports()) instead of comparing version strings.
  • No admin UI, and no automatic uninstall of data other plugins may still need.

163 tests, verified against WordPress 5.9 / 6.5 / latest on PHP 7.4 and 8.3.