Advertisement
verygoodplugins

Untitled

Sep 3rd, 2020 (edited)
1,104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.87 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.  
  9.         add_filter( 'wpf_user_register', 'my_wpf_user_register', 10, 2 );
  10.  
  11.         wp_fusion()->user->user_register( $user_id );
  12.     }
  13.  
  14. }
  15.  
  16. add_action( 'add_user_role', 'my_add_user_role', 10, 2 );
  17. add_action( 'set_user_role', 'my_add_user_role', 10, 2 );
  18.  
  19. function my_wpf_user_register( $post_data, $user_id ) {
  20.  
  21.     $post_data['user_email'] = get_user_meta( $user_id, '_company_email', true );
  22.  
  23.     return $post_data;
  24.  
  25. }
  26.  
  27. function my_wpf_get_contact_id_email( $email_address, $user_id ) {
  28.  
  29.     $company_email = get_user_meta( $user_id, '_company_email', true );
  30.  
  31.     if ( ! empty( $company_email ) ) {
  32.         $email_address = $company_email;
  33.     }
  34.  
  35.     return $email_address;
  36.  
  37. }
  38.  
  39. 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