Advertisement
verygoodplugins

Untitled

Aug 26th, 2024
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.75 KB | None | 0 0
  1. /**
  2.  * Filter user meta data pulled by WP Fusion and divide a specific field by 100.
  3.  *
  4.  * @param array $user_meta The array of user meta data.
  5.  * @param int   $user_id    The user ID.
  6.  * @return array $user_meta Modified user meta data.
  7.  */
  8. function custom_divide_user_meta_field_by_100( $user_meta, $user_id ) {
  9.     // Specify the field ID to be divided
  10.     $field_id = 'your_field_id';
  11.  
  12.     // Check if the field exists and is numeric
  13.     if ( isset( $user_meta[ $field_id ] ) && is_numeric( $user_meta[ $field_id ] ) ) {
  14.         // Divide the field value by 100
  15.         $user_meta[ $field_id ] = $user_meta[ $field_id ] / 100;
  16.     }
  17.  
  18.     return $user_meta;
  19. }
  20. add_filter( 'wpf_pulled_user_meta', 'custom_divide_user_meta_field_by_100', 10, 2 );
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement