WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Get all roles when you aren't logged into the system (5 posts)

  1. floweringmind
    Member
    Posted 4 years ago #

    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.

  2. MichaelH
    Member
    Posted 4 years ago #

    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.

  3. floweringmind
    Member
    Posted 4 years ago #

    Thanks!

  4. floweringmind
    Member
    Posted 4 years ago #

    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]

  5. MichaelH
    Member
    Posted 4 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.