WordPress.org

Codex

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

Function Reference/add users page

Description

Add sub menu page to the Users or Profile menu.

NOTE: If you're running into the »You do not have sufficient permissions to access this page.« message in a `wp_die()` screen, then you've hooked too early. The hook you should use is `admin_menu`.

Usage

 <?php
add_users_page
$page_title$menu_title$capability$menu_slug$function);
?> 

Parameters

$page_title
(string) (required) The text to be displayed in the title tags of the page when the menu is selected
Default: None
$menu_title
(string) (required) The text to be used for the menu
Default: None
$capability
(string) (required) The capability required for this menu to be displayed to the user.
Default: None
$menu_slug
(string) (required) The slug name to refer to this menu by (should be unique for this menu).
Default: None
$function
(callback) (optional) The function to be called to output the content for this page.
Default: ' '

Return Values

string 
The resulting page's hook_suffix (What add_submenu_page() returns)

Notes

  • This function is a simple wrapper for a call to add_submenu_page(), passing the received arguments and specifying 'users.php' or 'profile.php' (depending upon the users capability) as the $parent_slug argument. This means the new page will be added as a sub menu to the Users or Profile menu.
  • The $capability parameter is used to determine whether or not the page is included in the menu based on the Roles and Capabilities) of the current user.
  • The function handling the output of the options page should also verify the user's capabilities.
  • The Users menu is only available to users with the ability to edit other users. Users with capability below this level will see a Profile menu instead.

Example

Typical usage occurs in a function registered with the 'admin_menu' hook (see Adding Administration Menus):

add_action('admin_menu', 'my_users_menu');

function my_users_menu() {
	add_users_page('My Plugin Users', 'My Plugin', 'read', 'my-unique-identifier', 'my_plugin_function');
}

Source File

add_users_page() is located in wp-admin/includes/plugin.php.

Related

Administration Menus: add_menu_page(), remove_menu_page(), add_submenu_page(), remove_submenu_page(), add_dashboard_page(), add_posts_page(), add_media_page(), add_links_page(), add_pages_page(), add_comments_page(), add_theme_page(), add_plugins_page(), add_users_page(), add_management_page(), add_options_page()