How are roles stored in the database?

I know roles are defined but how are they stored in the database? For instance, how is "Super Admin" stored i.e. 'super_admin'?

Answers 1

  • The core functions:

    • is_super_admin(),
    • grant_super_admin(),
    • revoke_super_admin()

    fetch the super admins data from the wp_sitemeta table with:

    $super_admins = get_site_option( 'site_admins', array( 'admin' ) );

    It's stored as a serialized array of user logins, for each site, like:


    It's possible to override it with the global $site_admins array.

    On the other hand, the general user roles (admin, editor, author, ...) are stored as serialized arrays, for each user, like:


    in the wp_usermeta table under the wp_capabilities meta key and/or the wp_{$blog_id}_capabilities meta keys.

    Note that the wp_ prefix might be different on your install.

Related Questions