diff --git a/includes/class-twp-core.php b/includes/class-twp-core.php index 21c09b3..47a1096 100644 --- a/includes/class-twp-core.php +++ b/includes/class-twp-core.php @@ -17,6 +17,7 @@ class TWP_Core { $this->load_dependencies(); $this->set_locale(); + $this->ensure_user_roles(); $this->define_admin_hooks(); $this->define_public_hooks(); $this->define_api_hooks(); @@ -62,6 +63,31 @@ class TWP_Core { }); } + /** + * Ensure custom user roles exist + */ + private function ensure_user_roles() { + // Check if the phone_agent role exists + if (!get_role('phone_agent')) { + // Create the Phone Agent role with limited capabilities + add_role('phone_agent', 'Phone Agent', array( + // Basic WordPress capabilities + 'read' => true, + + // Profile management + 'edit_profile' => true, + + // Phone agent specific capabilities + 'twp_access_voicemails' => true, + 'twp_access_call_log' => true, + 'twp_access_agent_queue' => true, + 'twp_access_outbound_calls' => true, + 'twp_access_sms_inbox' => true, + 'twp_access_browser_phone' => true, + )); + } + } + /** * Register admin hooks */