Non-Super-Admins as Staff for Support System Plugin

I have a possible patch for the Support System Plugin to allow non-Super-Admins as staff that your devs might consider adding.

Replace the RETURN statement of the get_super_admins function in incsub-support.php with:

return apply_filters( 'incsub_support_get_super_admins', $super_admins, $super_admins );

This would allow something like the following to be added in a separate plugin (I have it as a mu-plugin) to designate staff who can access and answer tickets without themselves being super-admins on the multisite network.

=== MY MU-PLUGIN TO DESIGNATE NON-SUPER-ADMINs AS STAFF ===
<?php
function incsub_support_staff_users($super_admins) {
$staff_users = array();
$staff_users['2']="nonsuperadminsuser";

$new_admins = array();
foreach ( $staff_users as $ID => $user_login) {
$new_admins[ $ID ] = $user_login;
}
foreach ( $super_admins as $ID => $user_login) {
$new_admins[ $ID ] = $user_login;
}

return ($new_admins);

}

add_filter('incsub_support_get_super_admins','incsub_support_staff_users',999,1);
?>
=========END==========

I'm testing now and it can probably be tightened up a bit, is there anything I should watch out for using this solution?

-- Matt

  • dentm42

    Correct, 2 is the WP ID for the user.

    To be honest, I was a bit overzealous and hadn't finished testing. From what I can see so far, there are 2 other modifications that need to be made to make this work.

    (1) In incsub-support.php - add the following function:

    public static function is_staff($userid) {
    $userid = $userid ?: get_current_user_id();
    $staff=MU_Support_System::get_super_admins();
    if (array_key_exists("$userid",$staff)) return true;
    return false;
    }

    And in inc/helpers/capabilities.php make the following change in the function incsub_support_user_can:

    CHANGE:
    if ( ( is_multisite() && is_super_admin( $user_id ) ) || ( ! is_multisite() && user_can( $user_id, 'manage_options' ) ) ) {

    TO READ:
    if ( ( is_multisite() && MU_Support_System::is_staff( $user_id ) ) || ( ! is_multisite() && user_can( $user_id, 'manage_options' ) ) ) {

    I've run several tests and this seems to take care of everything - of course - your mileage may vary, but I think this will supply my need to not have everyone I want as "staff" having "super_admin" capabilities. I try not to even log in as a SUPER_ADMIN unless I need to to do something specific.

  • Jude

    Thanks for sharing this with the community dentm42 sending a couple of points your way ! Also sending a feature request to add this filter as part of the core plugin, going forward.

    Replace the RETURN statement of the get_super_admins function in incsub-support.php with:
    
    return apply_filters( 'incsub_support_get_super_admins', $super_admins, $super_admins );

    Thank you for being a WPMU DEV member and have a fantastic day!

    Cheers
    Jude

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.