Custom User Role Plugin Suggestion

Hi,

Could the community recommend a user role plugin that would allow me to create a new role that would let a user with that role view/access all sites on the network but NOT have access to the network admin pages?

The two candidates seem to be:

https://wordpress.org/plugins/advanced-access-manager/

https://wordpress.org/plugins/user-role-editor/

But the latter appears to need a paid for 'pro' version for the network version.

Anyone had to do this before and can make recommendation?

Thanks in advance.

Alex

  • Ivan

    Hey there Alex,

    Hope you are well today!

    To be honest I haven't really find anything that is free for multisite, it seems all of the role editor plugins are premium when it comes to multisite.

    For example this one -
    https://wordpress.org/plugins/wpfront-user-role-editor/

    You could check this page - https://wordpress.org/plugins/search.php?q=role+editor
    There is a lot of plugins and there might be some that will fit your needs.

    Of course it is always the best if some of our members can share plugin they are actually using. :slight_smile:

    Thanks,
    Ivan

  • Alex Furr

    OK - so I've got a solution if anyone wants to use it. To reiterate, the problem was we needed a new role on our network (call it an auditor role) that could VIEW and site on the network, but didn't have super admin network access. I ended up forking the fantastic Multisite Privacy plugin:
    https://premium.wpmudev.org/project/sitewide-privacy-options-for-wordpress-mu/

    This is what the new code does.
    1. Adds a new menu item to 'Network > Users' called 'Auditors
    2. On this new admin page you add users by username (username easier that email or userID in out experience)
    3. That list of users is stored as a network site option and those people can now view any site on the network, just not mess with things :slight_smile:

    The code is below. Hope its of some use. We are using an older version of the plugin, hence the reference to classes. Would be nice to incorporate this into the main plugin if possible so I can update in future without worry of deleting.

    ----------------------------------
    // Initialise new admin screens
    function __construct()
    {
    add_action( 'network_admin_menu', array( $this, 'ds_addNetworkAdminPage' ));
    }

    /**
    * Registers the Network Admin pages
    */
    function ds_addNetworkAdminPage()
    {
    //--- Root page
    $page_title = "Auditors";
    $menu_title = "Auditors";
    $capability = "manage_network_options"; //'manage_options' for administrators.
    $function = array( $this, 'drawDS_audit_users' );
    $parent = 'users.php';
    $menu_slug="network-auditor-list";

    add_submenu_page( $parent, $page_title, $menu_title, $capability, $menu_slug, $function );
    }

    // Draw the network admin auditors page
    function drawDS_audit_users()
    {
    echo '<h1>Auditors</h1>';
    if(isset($_GET['action']))
    {
    $action = $_GET['action'];
    $userArray = get_site_option('ds_auditors');

    switch($action)
    {

    case("addAuditor"):
    $username = trim($_POST['username']);
    $userCheck = get_user_by( 'login', $username);
    if($userCheck)
    {
    // They exist. Add them to the array
    $display_name = $userCheck->display_name;
    echo '<div class="updated">'.$display_name.' added as an auditor</div>';

    // Only add them if they are not already in the array
    if(!in_array($username, $userArray))
    {
    $userArray[] = $username;
    update_site_option('ds_auditors', $userArray);
    }
    }
    else
    {
    // They don't exist. Repor the error
    echo '<div class="error">Sorry, the username "'.$username.'" does not exist</div>';
    }
    break;

    case("removeAuditor"):
    $username = $_GET['username'];
    $userCheck = get_user_by( 'login', $username);
    if($userCheck)
    {
    $display_name = $userCheck->display_name;

    if(($key = array_search($username, $userArray)) !== false)
    {
    unset($userArray[$key]);
    // Turn the array back into a string and save to the option
    update_site_option('ds_auditors', $userArray);
    echo '<div class="updated">'.$display_name.' removed as an auditor</div>';
    }
    }

    break;
    }
    }

    $userArray = get_site_option('ds_auditors');

    echo '<form method="post" action="?page=network-auditor-list&action=addAuditor">';
    echo '<label for="username">Auditor Username</label>
    ';
    echo '<input type="text" name="username" id="username">';
    echo '<input type="submit" value="Add Audtior" class="button-primary">';
    echo '</form>';
    echo '<hr/>';

    if($userArray)
    {

    echo 'The following people can view ANY site within your network.
    However, they can only edit site settings / content if they have admin access to each site.<hr/>';

    echo '<table class="widefat fixed"><thead><tr><th>Name</th><th>Username</th><th>Email</th><th></th></thead></tr>';
    foreach($userArray as $username)
    {
    if($username)
    {
    $userInfo = get_user_by( 'login', $username);
    $display_name = $userInfo->display_name;
    $email= $userInfo->user_email;
    echo '<tr>';
    echo '<td>'.$display_name.'</td>';
    echo '<td>'.$username.'</td>';
    echo '<td>'.$email.'</td>';
    echo '<td>Remove</td>';
    echo '</tr>';
    }
    }
    echo '</table>';
    }
    else
    {
    echo 'No auditors found.';
    }
    }

    function check_is_auditor($username)
    {
    $globalReaderArray = get_site_option('ds_auditors');
    if(in_array($username, $globalReaderArray))
    {
    return true;
    }
    else
    {
    return false;
    }
    }

    /// Finally, when checking if they can view the page (in old version its ds_members_authenticator etc, in the new one the switch $privacy also call the check_is_auditor() function.

    Works on older plugin version, haven't tested on new one.

    Bottom line, wasn't too hard and think this would be a great addition to the standard plugin.
    Alex

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.