Function and usage of get_super_admins() in wordpress


Answers ( 1 )


    The get_super_admins() function in WordPress is a useful tool for retrieving a list of super administrators in a multisite network. Here's a detailed explanation of its function and a sample usage:

    Function: get_super_admins(): string[]

    • Purpose: This function is designed to fetch a list of the user logins who have super admin privileges in a WordPress multisite network.
    • Context: In a WordPress multisite environment, super admins have the highest level of access, allowing them to manage all aspects of the network, including all individual sites and other user roles.

    Return Value

    • Type: string[]
    • Description: The function returns an array of strings, where each string represents the login name of a super admin.

    Sample Usage

    // Check if the function exists to ensure compatibility
    if (function_exists('get_super_admins')) {
        // Fetch the list of super admin logins
        $super_admins = get_super_admins();
        // Example usage: Loop through the list and display each super admin login
        echo 'List of Super Admins:<br>';
        foreach ($super_admins as $admin) {
            echo $admin . '<br>';
    } else {
        echo 'This function is not available in your WordPress installation.';

    In this sample, the code first checks if the get_super_admins() function exists to prevent errors in installations where it might not be available (especially in non-multisite environments). It then retrieves the list of super admin logins and iterates through it, displaying each login. This can be particularly useful for debugging or administrative purposes within a multisite network.

Leave an answer