Fix browser phone client name to be alphanumeric only

- 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 <noreply@anthropic.com>
This commit is contained in:
2025-08-13 10:15:39 -07:00
parent 140a585085
commit c0f0ea8158

View File

@@ -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);