is_user_admin()
Checks if the requested page is a user page in the admin area, in a multisite network. For example: /wp-admin/user/ or /wp-admin/user/profile.php. Conditional tag.
This function is part of a group of functions:
- is_admin() - any admin page...
- is_network_admin() - admin page in the network management section.
- is_blog_admin() - admin page in the management section of a single site, not a network of sites.
- is_user_admin() - special user page in the WordPress admin.
I did not find access to this page from the WordPress interface... You can only access it directly... Therefore, this function is practically useless, because no one goes to this page. For example, it redirects to such pages when updating WordPress, when we see "What's new in WordPress?".
Does not determine if the user is an admin! For this, use permission checks with current_user_can().
Works based on the global variable $current_screen.
No Hooks.
Returns
true|false. True - if inside the user administration page in WordPress MU.
Usage
if( is_user_admin() ){
//
}
Examples
#1 Display the link to the profile in /user/ if we are already in this section.
Example from the get_edit_profile_url() function code.
if ( is_user_admin() ) $url = user_admin_url( 'profile.php', $scheme ); elseif ( is_network_admin() ) $url = network_admin_url( 'profile.php', $scheme ); else $url = get_dashboard_url( $user_id, 'profile.php', $scheme );
Notes
- Global. WP_Screen.
$current_screenWordPress current screen object.
Changelog
| Since 3.1.0 | Introduced. |
is_user_admin() is user admin code WP 6.9.1
function is_user_admin() {
if ( isset( $GLOBALS['current_screen'] ) ) {
return $GLOBALS['current_screen']->in_admin( 'user' );
} elseif ( defined( 'WP_USER_ADMIN' ) ) {
return WP_USER_ADMIN;
}
return false;
}