Advertisement
Guest User

EDD New User Notification (remove admin notification)

a guest
Jun 26th, 2019
502
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.16 KB | None | 0 0
  1. <?php
  2.  
  3. function edd_new_user_notification_custom( $user_id = 0, $user_data = array() ) {
  4.  
  5.     if( empty( $user_id ) || empty( $user_data ) ) {
  6.         return;
  7.     }
  8.     $emails     = EDD()->emails;
  9.     $from_name  = edd_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
  10.     $from_email = edd_get_option( 'from_email', get_bloginfo( 'admin_email' ) );
  11.  
  12.     // Setup and send the new user email for the end user.
  13.     $user_subject  = apply_filters( 'edd_user_registration_email_subject', sprintf( __( 'New account created', 'easy-digital-downloads' ), $from_name ), $user_data );
  14.     $user_heading  = apply_filters( 'edd_user_registration_email_heading', __( 'Your account info', 'easy-digital-downloads' ), $user_data );
  15.  
  16.     $user_message  = apply_filters( 'edd_user_registration_email_username', sprintf( __( 'Username: %s', 'easy-digital-downloads' ), $user_data['user_login'] ) . "\r\n", $user_data );
  17.  
  18.     if ( did_action( 'edd_pre_process_purchase' ) ) {
  19.         $password_message = __( 'Password entered at checkout', 'easy-digital-downloads' );
  20.     } else {
  21.         $password_message = __( 'Password entered at registration : Test', 'easy-digital-downloads' );
  22.     }
  23.  
  24.     $user_message .= apply_filters( 'edd_user_registration_email_password', sprintf( __( 'Password: %s', 'easy-digital-downloads' ), '[' . $password_message . ']' ) . "\r\n" );
  25.  
  26.     $login_url = apply_filters( 'edd_user_registration_email_login_url', wp_login_url() );
  27.     if($emails->html){
  28.         $user_message .= '<a href="' . $login_url . '"> ' . esc_attr__( 'Click here to log in', 'easy-digital-downloads' ) . ' &raquo;</a>' . "\r\n";
  29.     } else {
  30.         $user_message .= sprintf( __( 'To log in, visit: %s', 'easy-digital-downloads' ), $login_url ) . "\r\n";
  31.     }
  32.  
  33.     $user_message = apply_filters( 'edd_user_registration_email_message', $user_message, $user_data );
  34.  
  35.     $emails->__set( 'heading', $user_heading );
  36.  
  37.     $emails->send( $user_data['user_email'], $user_subject, $user_message );
  38.  
  39. }
  40.  
  41. remove_action('edd_insert_user', 'edd_new_user_notification');
  42. add_action('edd_insert_user', 'edd_new_user_notification_custom',10,2);
  43.  
  44. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement