email - Duplicate notifications for new user registration

admin2025-01-07  5

I am trying to figure out why new user registrations are receiving duplicate notification emails. They arrive at the exact same time but from different addresses, one is from the admin owner (myself) and the other one from [email protected]. I am using a custom registration form. Here are the relevant pieces of code:

// auto generate a password
$user_pass = wp_generate_password();

// setup new user
$userdata = array(
    'user_pass' => $user_pass,
    'user_login' => esc_attr( $_POST['user_name'] ),
    'user_email' => esc_attr( $_POST['email'] ),
    'first_name' => esc_attr( $_POST['firstname'] ),
    'last_name' => esc_attr( $_POST['lastname'] )
);

//insert it in db
$new_user = wp_insert_user( $userdata );

//send notification to user
wp_new_user_notification($new_user, $user_pass);

Any help would be appreciated.

I am trying to figure out why new user registrations are receiving duplicate notification emails. They arrive at the exact same time but from different addresses, one is from the admin owner (myself) and the other one from [email protected]. I am using a custom registration form. Here are the relevant pieces of code:

// auto generate a password
$user_pass = wp_generate_password();

// setup new user
$userdata = array(
    'user_pass' => $user_pass,
    'user_login' => esc_attr( $_POST['user_name'] ),
    'user_email' => esc_attr( $_POST['email'] ),
    'first_name' => esc_attr( $_POST['firstname'] ),
    'last_name' => esc_attr( $_POST['lastname'] )
);

//insert it in db
$new_user = wp_insert_user( $userdata );

//send notification to user
wp_new_user_notification($new_user, $user_pass);

Any help would be appreciated.

Share Improve this question edited May 9, 2014 at 20:46 amespower asked May 9, 2014 at 19:53 amespoweramespower 4185 silver badges17 bronze badges 4
  • Do any emails go out if you remove the wp_new_user_notification($new_user, $user_pass)? Also, do both emails contain the exact same content? – czerspalace Commented May 9, 2014 at 21:08
  • No, they won't go at all if I remove that, so both seem to be coming from that function. Exact same content, although the one with my admin name has everything all on one line instead of formatted with a line break. – amespower Commented May 9, 2014 at 21:31
  • What happens if you use the included registration form? Are you using a plugin for the form? Have you tried disabling all plugins? – czerspalace Commented May 9, 2014 at 21:51
  • Turns out it was indeed conflict with another plugin. I had done a search for wp_new_user_notification but none of my plugins were using it, however wp_mail was used. Removing that plugin fixed it. Thanks. – amespower Commented May 15, 2014 at 16:54
Add a comment  | 

1 Answer 1

Reset to default 0

when you call the wp_new_user_notification()function an email is send to the user and to the admin.

other plugins or themes can create their own wp_new_user_notification() function. if that's the case then you need to check that function.

Regards

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736255416a280.html

最新回复(0)