Support System - lower required capabilities for admin

Hey Guys, I'm using the support system plugin on a single site install of WP. Is there a way, (even if by altering the code), to allow the admin user to assign tickets to users with the role of author. As I understand it, currently the admin is only able to assign tickets to other admin users.

Thanks,
Dana

  • Dana

    Hey Vinod, Thanks for the quick reply. I was hoping this could be a matter of changing a role here or there, but that particular change didn’t work. The results were as follows.

    In “General Settings” under” Main Administrator” the admin user (default) was removed and replaced with the author user, but the author user / role didn’t gain any functionality.

    The admin role still functions the same. The only thing this seemed to change is the “Staff Representative” field which now displays the author user only - the admin user is missing.

    Thanks,
    Dana

  • Vaughan

    Hi @dana,

    As far as I can tell, the user needs to have mange_options capability.

    I'm not sure if we could change this in the plugin in all places, so that a capability for authors and above will work.

    I may need to ask one of our developers about that. If we simply change it, then the author will have capabilities to change all the settings and priority of tickets too, such as status etc.

    Hopefully the developer should know more.

    Thanks

  • Dana

    Hey Vaughan, thanks for the update. Yes, I was afraid this might not be so simple. Ideally, the author would be capable of responding to tickets, but not have the authority to change the plugin settings or even ticket status.

    Whatever the outcome of this request, this is still a great, highly useful plugin and I appreciate all the help. I will be looking forward to hearing what might be able to be modified here.

    Thanks again,
    Dana

  • Jose

    Hi there @Dana,

    Hope you are doing well today :slight_smile:.

    I was taking a look into this, and the support given by @Vinod Dalvi
    and @Vaughan is correct:
    - The code fix provided by Vinod will populate the dropdown list for assignments with the name of the users holding an 'Author' role.
    - Vaughan is correct, the pages to manage the tickets will load only for users with capabilities over 'manage_options'.

    So, in order for this to work, I added a few more lines of code into incsup-support.php:

    if ( $admin_ticket_menu_allowed ) {
      $admin_users = MU_Support_System::get_super_admins();
      if(in_array($user->user_login, $admin_users)){
        self::$network_main_menu = new MU_Support_Network_Main_Menu( false, 'edit_published_posts' );
        self::$network_single_ticket_menu = new MU_Support_Network_Single_Ticket_Menu( false, false, 'edit_published_posts' );
        self::$network_ticket_categories = new MU_Support_Network_Ticket_Categories( false, 'edit_published_posts' );
        self::$network_single_faq_question_menu = new MU_Support_Network_Single_FAQ_Question_Menu( false, 'edit_published_posts' );
        self::$network_faq_manager_menu = new MU_Support_Network_FAQ_Manager_Menu( false, 'edit_published_posts' );
        self::$network_faq_categories_menu = new MU_Support_Network_FAQ_Categories( false, 'edit_published_posts' );
        self::$network_support_settings_menu = new MU_Support_Network_Support_settings( false, 'edit_published_posts' );
     } else {
        self::$admin_single_ticket_menu = new MU_Support_Admin_Single_Ticket_Menu();
        self::$admin_new_ticket_menu = new MU_Support_Admin_New_Ticket_Menu();
        self::$admin_main_menu = new MU_Support_Admin_Main_Menu();
       }
    }

    I'm attaching the modified file so that you can simply replace it and test on your end.

    Note that, as Vaughan mentioned, it will allow not only to answer the tickets, but also to change ticket priority and status.
    If you want to give specific permissions, then you will need to work on the file network-single-ticket-menu.php to add conditional exceptions.

    Please replace the file and let us know if it works as expected.

    Cheers!
    JJ

  • wp.network

    Hey @Dana

    This seems useful. I love the idea of being able to assign some tickets to editors or even to authors!

    I can also see perhaps not wanting such users to be able to close the ticket... it'd be sweet to have a way so that authors or editors assigned tickets can mark as 'ready for review' or some such when they thought the ticket was solved and ready for admin approval.

    In any case, thanks for having such a fun idea! I'm also looking forward to hearing of your success. Please do share what works for you. :slight_smile:

    Regards,
    Max

  • Dana

    Hey Jose, NICE WORK! The Author role is able to respond to tickets. I have tested this, trading tickets between the Admin and test user(subscriber who submitted the ticket) and also the author and test user. Both author and admin both receive all email updates – Very Cool! The only glitch I see is the same as before with Vinod’s code fix is that the Author role is the only role available for the “Main Administrator” under “Settings” – meaning the admin can’t be seen or chosen obviously. I shouldn’t even say “glitch” because Vinod may very well have intended this behavior (just authors available in this dropdown and not authors and admins) but I’m thinking Vinod’s code fix could be expanded to include bother author and administrator to solve this.

    And yes, I will dig into network-single-ticket-menu.php for any further customizations. Max had some really interesting ideas.
    Vinod, Jack, Vaughan, Max, and Jose, Thanks so much!

    I will report further customizations.
    Dana

  • Jose

    Hi @Dana,

    Thank for the feedback!

    In order to sort the "glitch", you need to replace the following method declaration in line 396:

    Currently, it is like this:

    public static function get_super_admins() {
    
    			if ( is_multisite() ) {
    				$super_admins = get_super_admins();
    			}
    			else {
    				$admins = get_users(
    					array(
    						'role' => 'author, administrator',
    						'fields' => array( 'ID', 'user_login' )
    					)
    				);
    
    				$super_admins = array();
    				foreach ( $admins as $admin ) {
    					$super_admins[ $admin->ID ] = $admin->user_login;
    				}
    
    			}
    
    			return $super_admins;
    		}

    You need to replace it using this:

    public static function get_super_admins() {
    
                $super_admins = array();
                $roles = array('author', 'administrator');
    
                foreach ($roles as $role){
                    $admins = get_users(
                        array(
                            'role' => $role,
                            'fields' => array( 'ID', 'user_login' )
                        )
                    );
                    if ($admins) {
                        foreach ( $admins as $admin ) {
                            $super_admins[ $admin->ID ] = $admin->user_login;
                        }
                    }
                }
                return $super_admins;
            }

    Of course, you can add/remove roles from the array to fit your needs:
    $roles = array('author', 'administrator');

    Note: It might need some improvement to behave nicely in multisite installations.

    Let me know if it works fine for you. :slight_smile:

    Cheers!

  • Greg

    @Vaughan and @dana

    Is this something that will be integrated into a normal update in a soon to be released version as well? If I do this manually, wouldn't it break upon future updates? I don't think I would want to have to make a note to remind myself to adjust every time a update happens.

    I hope you can incorporate it to make a standard feature (as this is pretty important I think in my opinion) to allow others to respond/control in the backend but not allow them access to admin components.

    :slight_smile:

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.