Skip to content

Commit befaee3

Browse files
committed
✨ Hide admin custom fields pre-filled from returning visitors when 'uempty' show condition is set
- In lhchatvalidator.php, skip processing admin custom fields during chat validation if the 'showcondition' is 'uempty' and the visitor already has a non-default nickname set - In onlinesettings.php, update the identifier_prefill for fields with 'uempty' showcondition to use 'Username' instead of the field's own identifier, ensuring the frontend correctly evaluates whether to show the field
1 parent e8ecf92 commit befaee3

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

lhc_web/lib/core/lhchat/lhchatvalidator.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,11 @@ public static function validateStartChat(& $inputForm, & $start_data_fields, & $
736736
if (is_array($customAdminfields)) {
737737

738738
foreach ($customAdminfields as $key => $adminField) {
739-
739+
740+
if (isset($adminField['showcondition']) && $adminField['showcondition'] === 'uempty' && $chat->nick !== 'Visitor' && !empty($chat->nick)) {
741+
continue;
742+
}
743+
740744
$fieldName = self::extractFieldName($adminField);
741745

742746
if (

lhc_web/modules/lhwidgetrestapi/onlinesettings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ function getValueFromPrefillOrLocation(erLhcoreClassModelChat $chatPrefill, str
639639
'required' => $adminField['isrequired'] == 'true',
640640
'name' => 'value_items_admin_'. $key,
641641
'identifier' => 'value_items_admin_' . $key,
642-
'identifier_prefill' => $adminField['fieldidentifier'],
642+
'identifier_prefill' => (isset($adminField['showcondition']) && $adminField['showcondition'] === 'uempty' ? 'Username' : $adminField['fieldidentifier']),
643643
'hide_prefilled' => ((isset($adminField['hide_prefilled']) && $adminField['hide_prefilled'] == true) ? true : false),
644644
'value' => $adminField['defaultvalue'],
645645
'priority' => ((isset($adminField['priority']) && is_numeric($adminField['priority'])) ? (int)$adminField['priority'] : 200)

0 commit comments

Comments
 (0)