Skip to content

Custom User Taxonomies

John James Jacoby edited this page Sep 10, 2026 · 1 revision

Custom User Taxonomies

Create a WP_User_Taxonomy during init to add another classification:

add_action( 'init', function() {
    new WP_User_Taxonomy(
        'department',
        'users/department',
        array(
            'singular'  => 'Department',
            'plural'    => 'Departments',
            'managed'   => true,
            'exclusive' => true,
        )
    );
} );

The constructor accepts:

  1. Taxonomy name, such as department.
  2. Rewrite slug, such as users/department.
  3. Taxonomy arguments. In addition to WordPress taxonomy arguments, the plugin recognizes singular, plural, managed, exclusive, and user_group.
  4. Optional label overrides.
  5. Optional capability overrides.

Important arguments

  • user_group identifies the taxonomy to wp_get_user_groups(); defaults to true for WP_User_Taxonomy instances.
  • exclusive changes the assignment interface from multiple selection to a single selection.
  • managed restricts assignment by ordinary users while retaining administrator management.
  • show_ui controls the administration UI and Users column.
  • hierarchical defaults to true.
  • public defaults to false.

Replace a default taxonomy

Remove its registration callback before the default priority, then register your replacement:

add_action( 'init', function() {
    remove_action( 'init', 'wp_register_default_user_type_taxonomy' );
}, 0 );

The equivalent Groups callback is wp_register_default_user_group_taxonomy.

Put durable customizations in a small functionality plugin rather than a theme, so changing themes does not remove the taxonomy registration.

Object types

User taxonomies attach to the user object type by default. The wp_user_groups_taxonomy_objects filter can change that array, but mixing object types is risky because IDs from different object tables can collide.

Clone this wiki locally