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:
@@ -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);
|
||||
|
Reference in New Issue
Block a user