Advertisement
wclovers

Untitled

Jul 28th, 2023
918
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.30 KB | None | 0 0
  1. add_filter('wcfm_membership_registration_fields', function ($fields) {
  2.     foreach(['first_name','last_name'] as $field_name) {
  3.         if (isset($fields[$field_name])) {
  4.             if (isset($fields[$field_name]['custom_attributes']) && is_array($fields[$field_name]['custom_attributes'])) {
  5.                 $fields[$field_name]['custom_attributes']['required'] = true;
  6.             } else {
  7.                 $fields[$field_name]['custom_attributes'] = ['required' => true];
  8.             }
  9.         }
  10.     }
  11.  
  12.     return $fields;
  13. });
  14.  
  15. add_filter('wcfm_membership_registration_fields_address', function ($fields) {
  16.     if (isset($fields['city'])) {
  17.         if (isset($fields['city']['custom_attributes']) && is_array($fields['city']['custom_attributes'])) {
  18.             $fields['city']['custom_attributes']['required'] = true;
  19.         } else {
  20.             $fields['city']['custom_attributes'] = ['required' => true];
  21.         }
  22.     }
  23.  
  24.     if (isset($fields['zip'])) {
  25.         $fields['zip']['label'] = __('Postcode', 'wc-frontend-manager');
  26.     }
  27.    
  28.     return $fields;
  29. });
  30.  
  31. add_filter('wcfm_membership_registration_fields_phone', function ($fields) {
  32.     if (isset($fields['phone'])) {
  33.         $fields['phone']['label'] = __('Contact number', 'wc-frontend-manager');
  34.     }
  35.    
  36.     return $fields;
  37. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement