WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/wp dropdown roles

Description

Generates a list of editable user roles as options for a select box.

Usage

<?php wp_dropdown_roles$selected ); ?>

Parameters

$selected
(string) (optional) Slug for the role that should be already selected.
Default: false

Return Values

This function does not return a value. Its output is echo'd directly.

Examples

If you would like to set a default role for the dropdown, provide the slug for the desired role as a parameter. The following example creates a dropdown of user roles with the "Editor" role as the default, selected value:

<select>
   <?php wp_dropdown_roles( 'editor' ); ?>
</select>

Change Log

Since: 2.1.0

Source File

wp_dropdown_roles() is located in wp-admin/includes/template.php

Related

Roles and Capabilities:

List & Dropdown Functions

Resources