cloudcatch / user-roles-table
A WordPress plugin that boosts WP_User_Query performance by adjusting SQL queries to use a custom user roles table, reducing overhead and improving scalability.
Installs: 4
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Type:wordpress-plugin
Requires
- php: >=8.0
Requires (Dev)
This package is auto-updated.
Last update: 2025-03-02 11:36:30 UTC
README
A lightweight and efficient WordPress plugin that mirrors user roles into a custom database table to optimize performance for WP_User_Query
and get_users()
calls. By offloading role-based queries to a dedicated table, this plugin reduces database overhead, making large-scale user management faster and more reliable.
Installation
Install and activate the plugin. This should automatically install the database table: wp_user_roles
.
Run the following command to copy all user role data to the new wp_user_roles
table:
wp user-roles-table migrate
This command will extract all users roles and capabilities from wp_postmeta
, and insert this data is a more performant schema in the wp_user_roles
database table.
Running Unit Tests
To ensure the plugin works as expected, you can run the included unit tests. Follow the steps below:
Prerequisites
- Make sure you have Docker installed and running on your machine (required for
wp-env
). - Ensure you have Composer installed to manage PHP dependencies.
Steps to Run Tests
- Start the WordPress Environment:
Use
wp-env
to spin up a local WordPress environment:wp-env start
- Install Dependencies:
If you haven't already, install the Composer dependencies:
composer install
- Run the Tests:
Execute the Composer test script to run the unit tests:
composer test