Example 1 — Default drop-down
Print a select box with all users.
<?php wp_dropdown_users(); ?> How It Works
- With no arguments, the select is named
user. - Each user becomes one
<option>. - The option text is the display name.

In WordPress, wp_dropdown_users() creates an HTML <select> drop-down that lists users from your site.
It is useful for admin screens, settings pages, and forms where you must choose a user. By default it prints the select box. Set echo to false to get the HTML as a string.
Call it with no arguments, or pass an array of options.
wp_dropdown_users();
wp_dropdown_users( array(
'name' => 'post_author',
'selected' => 1,
) ); | Call | What it does |
|---|---|
wp_dropdown_users() | Prints a select box named user with all users. |
wp_dropdown_users( $args ) | Prints a select box with your options, such as the name or the selected user. |
Place the call inside a <form>. This function is for forms, not for The Loop.
wp_dropdown_users( array|string $args = '' ): string | Parameter | Description |
|---|---|
$args | Optional. An array of options. See the table below. |
| Argument | What it does |
|---|---|
name | The name of the select box. Default is user. |
selected | The user ID that is selected at first. |
show | The user field shown as text. Default is display_name. |
include, exclude | Arrays of user IDs to add or remove. |
role | Show only users with this role, such as editor. |
show_option_all | Adds a first option, such as "All users". |
echo | true prints the HTML. false returns it. |
| Return Value | Description |
|---|---|
| string (HTML) | The <select> HTML. It is also printed when echo is true, which is the default. |
Three short examples. Each one has sample output.
Print a select box with all users.
<?php wp_dropdown_users(); ?> user.<option>.Choose a field name and pick one user at first.
<?php
wp_dropdown_users( array(
'name' => 'post_author',
'selected' => 2,
) );
?> name sets the field name that your form sends.selected picks the user with ID 2.selected='selected'.Show only one role and return the HTML.
<?php
$html = wp_dropdown_users( array(
'name' => 'editor_id',
'role' => 'editor',
'echo' => false,
) );
echo $html;
?> role keeps only editors.echo => false returns the HTML instead of printing it.echo $html.Browse all ten author functions in one table.
9 people found this page helpful