Allow Agents to Add and Edit Customers
By default, only support workers with the Support Manager role are able to view customer details as well as add and edit customers, however, it is very easy to allow agents to add and edit customers if you need them need to do so.
It is possible to enable support workers with the Support Agent role to carry out these tasks by inserting two simple functions which will filter the required capability.
Enable the Customer Menu Option
By hooking into the kbs_view_customers_role
filter, you can enable the display of the Customers and Companies menu options for Support Agents. This will enable a Support Agent to be able to list all customers, add new customers, and view an existing customer’s details;
/** * Enable the customers and companies menu options for agents * * @param string $customer_view_role The required capability * @return string Filtered required capability */ function kbs_custom_show_agents_customer_menu( $customer_view_role ) { if ( current_user_can( 'support_agent' ) ) { $customer_view_role = 'support_agent'; } return $customer_view_role; } // kbs_custom_show_agents_customer_menu add_filter( 'kbs_view_customers_role', 'kbs_custom_show_agents_customer_menu' );
Enable Editing of Existing Customers
Hooking into the kbs_edit_customers_role
filter will also enable Support Workers to be able to edit the details of a customer;
/** * Enable agents to edit a customer's details * * @param string $customer_edit_role The required capability * @param string Filtered required capability */ function kbs_custom_agents_can_edit_customers( $customer_edit_role ) { if ( current_user_can( 'support_agent' ) ) { $customer_edit_role = 'support_agent'; } return $customer_edit_role; } // kbs_custom_agents_edit_customers add_filter( 'kbs_edit_customers_role', 'kbs_custom_agents_can_edit_customers' );