WordPress wp_dropdown_users() Function

Beginner
4 min read
Updated: Nov 2026
3 examples
Template tag

Definition

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.

Syntax

Call it with no arguments, or pass an array of options.

WordPress
wp_dropdown_users();
wp_dropdown_users( array(
  'name'     => 'post_author',
  'selected' => 1,
) );
CallWhat 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.

Full declaration
WordPress
wp_dropdown_users( array|string $args = '' ): string

Parameters

ParameterDescription
$argsOptional. An array of options. See the table below.

Common arguments

ArgumentWhat it does
nameThe name of the select box. Default is user.
selectedThe user ID that is selected at first.
showThe user field shown as text. Default is display_name.
include, excludeArrays of user IDs to add or remove.
roleShow only users with this role, such as editor.
show_option_allAdds a first option, such as "All users".
echotrue prints the HTML. false returns it.

Return Value

Return ValueDescription
string (HTML)The <select> HTML. It is also printed when echo is true, which is the default.

WordPress Examples

Three short examples. Each one has sample output.

Example 1 — Default drop-down

Print a select box with all users.

WordPress
<?php wp_dropdown_users(); ?>

How It Works

  1. With no arguments, the select is named user.
  2. Each user becomes one <option>.
  3. The option text is the display name.

Example 2 — Name and selected user

Choose a field name and pick one user at first.

WordPress
<?php
wp_dropdown_users( array(
  'name'     => 'post_author',
  'selected' => 2,
) );
?>

How It Works

  1. name sets the field name that your form sends.
  2. selected picks the user with ID 2.
  3. That option gets selected='selected'.

Example 3 — Only editors, saved in a variable

Show only one role and return the HTML.

WordPress
<?php
$html = wp_dropdown_users( array(
  'name' => 'editor_id',
  'role' => 'editor',
  'echo' => false,
) );
echo $html;
?>

How It Works

  1. role keeps only editors.
  2. echo => false returns the HTML instead of printing it.
  3. You print it later with echo $html.

Frequently Asked Questions

It creates an HTML select drop-down that lists users from your WordPress site.
By default it prints. Pass 'echo' => false to return the HTML as a string.
Use the name argument, for example 'name' => 'post_author'.
Use the role argument, for example 'role' => 'editor'.
Use the selected argument with the user ID.
No. It is for forms and admin screens where someone must choose a user.

Next: wp_list_authors()

Browse all ten author functions in one table.

wp_list_authors() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful