Advertisement
verygoodplugins

Untitled

Sep 9th, 2020
1,114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.01 KB | None | 0 0
  1. function my_add_user_role( $user_id, $role ) {
  2.  
  3.     if ( ! function_exists( 'wp_fusion' ) ) {
  4.         return;
  5.     }
  6.  
  7.     if ( 'enabled' == $role ) {
  8.         wp_fusion()->user->user_register( $user_id );
  9.     }
  10.  
  11. }
  12.  
  13. add_action( 'add_user_role', 'my_add_user_role', 10, 2 );
  14. add_action( 'set_user_role', 'my_add_user_role', 10, 2 );
  15.  
  16. function my_wpf_user_register( $post_data, $user_id ) {
  17.  
  18.     $company_email = get_user_meta( $user_id, '_company_email', true );
  19.  
  20.     if ( ! empty( $company_email ) ) {
  21.         $post_data['user_email'] = $company_email;
  22.     }
  23.  
  24.     return $post_data;
  25.  
  26. }
  27.  
  28. add_filter( 'wpf_user_register', 'my_wpf_user_register', 10, 2 );
  29. add_filter( 'wpf_user_update', 'my_wpf_user_register', 10, 2 );
  30.  
  31. function my_wpf_get_contact_id_email( $email_address, $user_id ) {
  32.  
  33.     $company_email = get_user_meta( $user_id, '_company_email', true );
  34.  
  35.     if ( ! empty( $company_email ) ) {
  36.         $email_address = $company_email;
  37.     }
  38.  
  39.     return $email_address;
  40.  
  41. }
  42.  
  43. add_filter( 'wpf_get_contact_id_email', 'my_wpf_get_contact_id_email', 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement