verygoodplugins

Untitled

Sep 6th, 2025
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.16 KB | None | 0 0
  1. function ed_format_champs_wpfusion( $user_meta, $user_id ) {
  2.    
  3.     // Define fields that need uppercase formatting
  4.     $uppercase_fields = array(
  5.         'ACF_nom',
  6.         'ACF_derniere_entreprise',
  7.         'ACF_derniere_fonction',
  8.         'ACF_nouvelle_entreprise',
  9.         'ACF_nouvelle_fonction',
  10.         'ACF_cabinet'
  11.     );
  12.    
  13.     // Process each field in the user meta
  14.     foreach ( $user_meta as $field_key => $field_value ) {
  15.        
  16.         // Check if this field needs uppercase formatting
  17.         if ( in_array( $field_key, $uppercase_fields ) ) {
  18.             // Apply uppercase and trim to text values
  19.             if ( is_string( $field_value ) ) {
  20.                 $user_meta[ $field_key ] = mb_strtoupper( trim( $field_value ) );
  21.             }
  22.         }
  23.        
  24.         // Handle phone number field - remove spaces
  25.         elseif ( $field_key === 'ACF_telephone_mobile' ) {
  26.             if ( is_string( $field_value ) ) {
  27.                 $user_meta[ $field_key ] = str_replace( ' ', '', $field_value );
  28.             }
  29.         }
  30.     }
  31.    
  32.     return $user_meta;
  33. }
  34. add_filter( 'wpf_user_register', 'ed_format_champs_wpfusion', 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment