is_super_admin

Home » Functions » is_super_admin

Function Name: is_super_admin

The is_super_admin function is a WordPress function that checks if the specified user is a super admin, which means they have the highest level of access to the WordPress site.

This function is mostly used in WordPress Multisite installations, where there are multiple sites running under a single WordPress installation. Super admins have access to all the sites, and can manage them from a single dashboard.

The is_super_admin function takes a user ID or a WP_User object as an input parameter, and returns a boolean value indicating whether the specified user is a super admin or not. If the user is a super admin, the function returns true, and if not, it returns false.

Here is an example usage code of is_super_admin:

$user_id = 1; $is_super_admin = is_super_admin($user_id);

// Check if the user is a super admin if($is_super_admin) { // Do something for super admins } else { // Do something for non-super admins }

In this example, we are checking if the user with the ID 1 is a super admin. If the user is a super admin, we execute some code specific to super admins, and if not, we execute some code specific to non-super admins.

Overall, is_super_admin is a useful function for WordPress developers working with Multisite installations who need to check the permissions of specific users.

Learn More on WordPress.org

Register an account to save your snippets or go Pro to get more features.