[wp-hackers] List all capabilities
Andrew Nacin
wp at andrewnacin.com
Thu Jan 20 18:50:56 UTC 2011
On Thu, Jan 20, 2011 at 1:18 PM, Ryan Bilesky <rbilesky at gmail.com> wrote:
> Ok I think I may have found it, all roles and capabilities appear to be
> stored in an option called (dbprefix)_user_roles in an array format like:
>
> array (
> 'rolename' => array (
> 'name' => 'rolename',
> 'capabilities' => array()
> )
> )
>
> Now it the a better method, or should I just
> global $wpdb;
> $roles = get_option($wpdb->prefix . 'user_roles');
> and then loop though each role and get it's capability array than merge.
Don't use get_option(), as role definitions might not be stored in the
database.
Use the $wp_roles global, which is a WP_Roles object. There you can inspect
->roles, ->role_names, ->role_objects (which in turn are WP_Role objects).
More information about the wp-hackers
mailing list