I have the following code in my mu-plugins.php file and the is_super_admin() function does not correctly result in true.

I am running v4.2.4

function check_for_superAdmin() {
    if ( is_super_admin() ) { echo 'I\'m a Super Admin !'; exit; }
add_action( 'wp_login', 'check_for_superAdmin' );

Can anyone see a reason why?



The code below returns empty for the current user login username. I wonder if I have my hook in the wrong place.

function check_for_superAdmin() {
    $curUser = wp_get_current_user();
    echo $curUser->user_login . ' is the user';
    if ( is_super_admin() ) { echo 'I am the Super Admin !'; exit; }
add_action( 'wp_login', 'check_for_superAdmin' );

Additional Notes:

function check_for_superAdmin($user_login, $user) {
    //$current_user = wp_get_current_user(); // THIS DOES NOT FIND THE CURRENT USER
    //echo $user; // THIS THROWS A SERVER 500 ERROR
add_action( 'wp_login', 'check_for_superAdmin', 10, 2 );
  • $current_user = wp_get_current_user(); does not work within the function() above
  • $user_login works within the function() above
  • $user results in a server 500 error
  • Are you sure the user is a superadmin? In WordPress Multisite, it's a special privilege - separate from the Admin role. Aug 5, 2015 at 22:38
  • Yes, in the user list it tags and shows as Super Admin @MattvanAndel. I added some notes to my OQ to this effect
    – tammy
    Aug 5, 2015 at 22:44

1 Answer 1


I got it to work as follows -- in mu-plugins directory, my superAdmin.php script looks like this:


function check_for_superAdmin($user_login, $user) {
    $current_user = get_userdatabylogin($user_login);
    if ( is_super_admin( $current_user->ID ) ) { // do these things }
    else { // do other things }
add_action( 'wp_login', 'check_for_superAdmin', 10, 2 );


Hope this helps someone wanting to hook the same way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.