Advertisement
Guest User

Untitled

a guest
Feb 10th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. add_action('comment_post','wp_000_reg_user',10,2);
  2. function wp_000_reg_user($comment_ID, $comment_approved) {
  3. if( 1 === $comment_approved ){
  4. $userdata = array(
  5. 'user_login' => sanitize_user($_POST['username']),
  6. 'user_email' => sanitize_email($_POST['useremail']),
  7. 'user_pass' => sanitize_email($_POST['userpass']),
  8. 'role' => 'subscriber',
  9. 'show_admin_bar_front' => false
  10. );
  11.  
  12. $user_id = wp_insert_user( $userdata ) ;
  13.  
  14. // On success.
  15. if ( ! is_wp_error( $user_id ) ) {
  16. wp_redirect( get_permalink() ); exit;
  17. }
  18.  
  19. } //end if
  20. } //end function
  21.  
  22. if ( !function_exists('wp_new_user_notification') ) {
  23. function wp_new_user_notification( $user_id, $plaintext_pass = '' ) {
  24. $user = new WP_User($user_id);
  25.  
  26. $user_login = stripslashes($user->user_login);
  27. $user_email = stripslashes($user->user_email);
  28.  
  29. $message = sprintf(__('New user registration on %s:'), get_option('blogname')) . "rnrn";
  30. $message .= sprintf(__('Username: %s'), $user_login) . "rnrn";
  31. $message .= sprintf(__('E-mail: %s'), $user_email) . "rn";
  32.  
  33. @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), get_option('blogname')), $message);
  34.  
  35. if ( empty($plaintext_pass) )
  36. return;
  37.  
  38. $message = __('Hi there,') . "rnrn";
  39. $message .= sprintf(__("Welcome to %s! Here's how to log in:"), get_option('blogname')) . "rnrn";
  40. $message .= wp_login_url() . "rn";
  41. $message .= sprintf(__('Username: %s'), $user_login) . "rn";
  42. $message .= sprintf(__('Password: %s'), $plaintext_pass) . "rnrn";
  43. $message .= sprintf(__('If you have any problems, please contact me at %s.'), get_option('admin_email')) . "rnrn";
  44. $message .= __('Thanks!');
  45.  
  46. wp_mail($user_email, sprintf(__('[%s] Your username and password'), get_option('blogname')), $message);
  47.  
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement