From c0f0ea81581a03ba93fbc1b69ebafcbdc45bd9c1 Mon Sep 17 00:00:00 2001 From: jknapp Date: Wed, 13 Aug 2025 10:15:39 -0700 Subject: [PATCH] Fix browser phone client name to be alphanumeric only MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Removed underscores and hyphens from client name generation - Using preg_replace to strip all non-alphanumeric characters - Twilio requires client names to contain only alphanumeric characters 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- includes/class-twp-twilio-api.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/includes/class-twp-twilio-api.php b/includes/class-twp-twilio-api.php index cb61df2..bc3c748 100644 --- a/includes/class-twp-twilio-api.php +++ b/includes/class-twp-twilio-api.php @@ -681,7 +681,12 @@ class TWP_Twilio_API { // Create client name if not provided if (!$client_name) { $current_user = wp_get_current_user(); - $client_name = 'agent_' . $current_user->ID . '_' . sanitize_title($current_user->display_name); + // Twilio requires alphanumeric characters only - remove all non-alphanumeric + $clean_name = preg_replace('/[^a-zA-Z0-9]/', '', $current_user->display_name); + if (empty($clean_name)) { + $clean_name = 'user'; + } + $client_name = 'agent' . $current_user->ID . $clean_name; } $capability = new \Twilio\Jwt\ClientToken($account_sid, $auth_token);