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.
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.
To ensure the plugin works as expected, you can run the included unit tests. Follow the steps below:
- Make sure you have Docker installed and running on your machine (required for
wp-env
). - Ensure you have Composer installed to manage PHP dependencies.
- 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