Advertisement
Guest User

Untitled

a guest
May 18th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: New Register Email Customizer
  4. Description: Changes the copy in the email sent out to new users
  5. */
  6.  
  7. // Redefine user notification function
  8. if ( !function_exists('wp_new_user_notification') ) {
  9.  
  10. function wp_new_user_notification( $user_id, $deprecated = null, $notify = '' ) {
  11.  
  12. if ( $deprecated !== null ) {
  13. _deprecated_argument( __FUNCTION__, '4.3.1' );
  14. }
  15.  
  16. $user = get_userdata( $user_id );
  17.  
  18. // Generate password
  19. $password = wp_generate_password( 12, false );
  20. wp_set_password( $password, $user_id );
  21.  
  22. // The blogname option is escaped with esc_html on the way into the database in sanitize_option
  23. // we want to reverse this for the plain text arena of emails.
  24. $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
  25. if ( 'user' !== $notify ) {
  26. $switched_locale = switch_to_locale( get_locale() );
  27. $message = sprintf( __( 'New user registration on your site %s:' ), $blogname ) . "\r\n\r\n";
  28. $message .= sprintf( __( 'Username: %s' ), $user->user_login ) . "\r\n\r\n";
  29. $message .= sprintf( __( 'Email: %s' ), $user->user_email ) . "\r\n";
  30. $message .= sprintf( __( 'Password: %s' ), $password ) . "\r\n";
  31. @wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] New User Registration' ), $blogname ), $message );
  32. if ( $switched_locale ) {
  33. restore_previous_locale();
  34. }
  35. }
  36. // `$deprecated was pre-4.3 `$plaintext_pass`. An empty `$plaintext_pass` didn't sent a user notification.
  37. if ( 'admin' === $notify || ( empty( $deprecated ) && empty( $notify ) ) ) {
  38. return;
  39. }
  40.  
  41. $switched_locale = switch_to_locale( get_user_locale( $user ) );
  42. $message = sprintf(__('Username: %s'), $user->user_login) . "\r\n\r\n";
  43. $message .= get_home_url(). '/wp-login.php/?redirect_to=/investor-center/' . "\n";
  44. $message .= sprintf(__('Username: %s'), $user->user_login) . "\n";
  45. $message .= sprintf(__('Password: %s'), $password ) . "\n\n";
  46. $message .= sprintf(__('If you have any problems, please contact me at %s.'), get_option('admin_email')) . "\n\n";
  47.  
  48. wp_mail($user->user_email, sprintf(__('[%s] Your username and password info'), $blogname), $message);
  49.  
  50. if ( $switched_locale ) {
  51. restore_previous_locale();
  52. }
  53.  
  54. }
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement