Hi, i had to modify for a client earlier so here is my quick hack. It adds checkboxes instead of a dropdown and will loop and send. It currently shows the user id, their login and their email address next to each checkbox (you could get user meta instead). You can replace everything below (but not including) <form method=”POST”> with the following and it should work.
<form method="POST">
<p>
<?php
$users = get_users('orderby=ID&order=DESC');
foreach ($users as $user) {
$user_info = get_userdata($user->ID);
$name = $user_info->user_login;
$useremails = $user_info->user_email;
// uncomment to set value for user id's to select with auto checked.
/*
if($user->ID > 240 && $user->ID < 854 ){
echo '<input type="checkbox" name="selectedusers[]" value="'.$user->ID.'" checked/> '.$user->ID.' --- '.$name.' ---------- '.$useremails.'<br/>';
}
*/
// uncomment if you want to select from all users individually.
echo '<input type="checkbox" name="selectedusers[]" value="'.$user->ID.'"/> '.$user->ID.' --- '.$name.' ---------- '.$useremails.'<br/>';
}?>
</p>
<p class="submit">
<input type="submit" class="button-primary" value="<?php _e('Send e-mail', 'resend_welcome_email') ?>" />
</p>
</form>
<?php
if (isset($_POST['selectedusers']))
{
foreach($_POST['selectedusers'] as $user){
echo $user;
$uid = $user;
// Generate a password
$password = substr(md5(uniqid(microtime())), 0, 7);
$user_info = get_userdata($uid);
wp_update_user(array('ID' => $uid, 'user_pass' => $password));
// Send welcome email (there might be a better function for this, I didn't check)
wp_new_user_notification($uid, $password);
$message = sprintf(__('E-mail sent for user %s.', 'resend_welcome_email'), $user_info->user_login);
printf('<div id="message" class="updated fade"><p>%s</p></div>', $message);
}
}
?>
</div><?php } ?>