Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action('comment_post','wp_000_reg_user',10,2);
- function wp_000_reg_user($comment_ID, $comment_approved) {
- if( 1 === $comment_approved ){
- $userdata = array(
- 'user_login' => sanitize_user($_POST['username']),
- 'user_email' => sanitize_email($_POST['useremail']),
- 'user_pass' => sanitize_email($_POST['userpass']),
- 'role' => 'subscriber',
- 'show_admin_bar_front' => false
- );
- $user_id = wp_insert_user( $userdata ) ;
- // On success.
- if ( ! is_wp_error( $user_id ) ) {
- wp_redirect( get_permalink() ); exit;
- }
- } //end if
- } //end function
- if ( !function_exists('wp_new_user_notification') ) {
- function wp_new_user_notification( $user_id, $plaintext_pass = '' ) {
- $user = new WP_User($user_id);
- $user_login = stripslashes($user->user_login);
- $user_email = stripslashes($user->user_email);
- $message = sprintf(__('New user registration on %s:'), get_option('blogname')) . "rnrn";
- $message .= sprintf(__('Username: %s'), $user_login) . "rnrn";
- $message .= sprintf(__('E-mail: %s'), $user_email) . "rn";
- @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), get_option('blogname')), $message);
- if ( empty($plaintext_pass) )
- return;
- $message = __('Hi there,') . "rnrn";
- $message .= sprintf(__("Welcome to %s! Here's how to log in:"), get_option('blogname')) . "rnrn";
- $message .= wp_login_url() . "rn";
- $message .= sprintf(__('Username: %s'), $user_login) . "rn";
- $message .= sprintf(__('Password: %s'), $plaintext_pass) . "rnrn";
- $message .= sprintf(__('If you have any problems, please contact me at %s.'), get_option('admin_email')) . "rnrn";
- $message .= __('Thanks!');
- wp_mail($user_email, sprintf(__('[%s] Your username and password'), get_option('blogname')), $message);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement