• yohanh

    (@yohanh)


    How can we identify which web pages are assigned to specific roles in the MySQL database when using the Custom Access Roles plugin, including the users assigned to those roles? Additionally, what is the meta_key for the Custom Access Roles plugin in the wp_postmeta table?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author room34

    (@room34)

    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 4 months ago by yohanh.
    Plugin Author room34

    (@room34)

    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'))

    • This reply was modified 4 months ago by room34.
    • This reply was modified 4 months ago by room34.
Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.