Support » Fixing WordPress » Get all roles when you aren’t logged into the system

  • Resolved floweringmind

    (@floweringmind)


    I need to get the array of all the roles. I was using $wp_roles which doesn’t work when you are logged out.

    Let be clear I am not looking for a user’s role, I am looking for what roles exist in the system.

    I figure I can do a query just not sure where this is being store. Options table most likely.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The option name wp30_user_roles in the options table will have that.

    Where ‘wp30_’ is the $table_prefix. I believe that value is serialized.

    Thanks!

    This is how I got the info:
    [code]
    $value = $wpdb->get_results(“SELECT option_value FROM wp_options WHERE option_name = ‘wp_user_roles'”);

    $value = get_option(‘wp_user_roles’);
    [/code]

    Note: use the backtick (below the tilde ~ on my keyboard) before and after the code block.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Get all roles when you aren’t logged into the system’ is closed to new replies.