All of the data for Custom Access Roles is stored in the wp_options table. Each role has an entry with option_name in the format of caroles_role_{role_slug} and the option_value containing a serialized array of all of the details of that role, including which pages, posts, categories, etc. it is assigned to, by ID. You can retrieve the data for a specific role using the get_option() function. Nothing is stored in wp_postmeta.
Thread Starter
yohanh
(@yohanh)
In “caroles_role_{role_slug}”, is “caroles” an example of a user?
Could you please share a sample SQL statement to select all users assigned to a role and the pages that each role is assigned to?
-
This reply was modified 1 year, 7 months ago by
yohanh.
No, caroles is the text domain prefix for the plugin. There’s an entry for each defined role, not for each user.
I would not recommend using SQL for this unless you’re trying to work with the data outside of WordPress, in which case this is a question about the WordPress database architecture, and while I do know how to construct the SQL queries, that’s outside of the scope of support for this plugin.
The role slugs are auto-generated by sanitizing the names of the roles. So if you have a custom role called “Test Role” then the slug for it is test_role and you can get the array of configuration details for that role, including a list of all of the pages/posts assigned to it, with this standard WordPress function:
get_option('caroles_role_test_role')
Likewise you can get a list of all of the users assigned to the role (but this time with the friendly name of the role, not the slug) with this standard WordPress function:
get_users(array('role' => 'Test Role'))