WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I edited the Add New User Profile page to add some custom fields (I'm not using multisite). My question is if there is a way to send out an activation/confirmation email to new users once I manually add them in?

Thanks!

share|improve this question

If you add a new user via the backend a confirmation email is sent automatically, unless you check the skip checkbox. The new user shouldn't appear in the UI until confirmed

share|improve this answer
    
When adding a user via the backend, the only option I have is "Send this password to the new user by email". However, it doesn't seem to work. Could it be because I'm using add_user_meta on the user_register action? – stevetronix Dec 7 '12 at 18:03
    
user meta etc should have no impact. I advise you test with a gmail account and the + feature to simulate multiple accounts – Tom J Nowell Dec 7 '12 at 18:55
up vote 1 down vote accepted

Solved it by adding this code to save_extra_profile_fields() in add_action ( 'user_register', 'save_extra_profile_fields');

$hash = md5( $random_number );
add_user_meta( $user_id, 'hash', $hash );

$user_info = get_userdata($user_id);
$to = $user_info->user_email;           

$subject = 'Member Verification'; 
$message = 'Hello,';
$message .= "\n\n";
$message .= 'Welcome...';
$message .= "\n\n";
$message .= 'Username: '.$un;
$message .= "\n";
$message .= 'Password: '.$pw;
$message .= "\n\n";
$message .= 'Please click this link to activate your account:';
$message .= home_url('/').'activate?id='.$un.'&key='.$hash;
$headers = 'From: noreply@test.com' . "\r\n";           
wp_mail($to, $subject, $message, $headers); 
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.