Codex

Template Tags/wp dropdown users

Contents

Description

Create dropdown HTML content of users.

Usage

 <?php wp_dropdown_users$args ); ?> 

Default Usage

 <?php $args = array(
    
'show_option_all'  => ,
    
'show_option_none' => 
,
    
'orderby'          => 'display_name',
    
'order'            => 'ASC',
    
'include'          => ,
    
'exclude'          => 
,
    
'multi'            => 0,
    
'show'             => 'display_name',
    
'echo'             => 1,
    
'selected'         => 0,
    
'name'             => 'user',
    
'class'            =>  ); ?> 

Parameters

show_option_all 
(string) Causes the HTML for the dropdown to allow you to select All of the users.
show_option_none 
(string) Causes the HTML for the dropdown to allow you to select NONE of the users.
orderby 
(string) Key to sort options by. Valid values:
  • 'ID'
  • 'user_nicename'
  • 'display_name' - Default
order 
(string) Sort order for options. Valid values:
  • 'ASC' - Default
  • 'DESC'
include 
(string) Comma separated list of users IDs to include. For example, 'include=4,12' means users IDs 4 and 12 will be displayed/echoed or returned. Defaults to exclude all.
exclude 
(string) Comma separated list of users IDs to exclude. For example, 'exclude=4,12' means users IDs 4 and 12 will NOT be displayed/echoed or returned. Defaults to exclude nothing.
multi 
(boolean) Whether to skip the ID attribute on the 'select' element.
  • 1 (True)
  • 0 (False) - Default
show 
(string) User table column to display. If the selected item is empty then the user_login will be displayed in parentesis.
  • 'ID'
  • 'user_login'
  • 'display_name' - Default
echo 
(boolean) Display bookmarks (TRUE) or return them for use by PHP (FALSE).
  • 1 (True) - Default
  • 0 (False)
selected 
(integer) User ID of the user to be 'selected' or presented in the display box. Defaults to no user selected.
name 
(string) Name assigned to the dropdown form. Defaults to 'user'.
class 
(string) Class assinged to the dropdown form.

Examples

Dropdown with Submit Button

Displays a users dropdown list in HTML form with a submit button.

<li id="users">
 <h2><?php _e('users:'); ?></h2>
   <form action="<?php bloginfo('url'); ?>" method="get">
   <?php wp_dropdown_users(); ?>
   <input type="submit" name="submit" value="view" />
   </form>
</li>

Change Log

Since: 2.3.0

Source File

wp_dropdown_users() is located in wp-includes/user.php.

Related

wp_list_authors, wp_list_categories, wp_list_pages, wp_list_bookmarks, wp_list_comments, wp_get_archives, wp_page_menu, wp_dropdown_pages, wp_dropdown_categories, wp_dropdown_users

See also index of Function Reference and index of Template Tags.