Adds a submenu page to the Users/Profile main menu.
This function takes a capability which will be used to determine whether or not a page is included in the menu.
The function which is hooked in to handle the output of the page must check that the user has the required capability as well.
$page_titlestringrequired
$menu_titlestringrequired
$capabilitystringrequired
$menu_slugstringrequired
$callbackcallableoptional
Default:''
$positionintoptional
Default:null
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.function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) {
if ( current_user_can( 'edit_users' ) ) {
$parent = 'users.php';
} else {
$parent = 'profile.php';
}
return add_submenu_page( $parent, $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
}
© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/add_users_page