Viewing 2 replies - 1 through 2 (of 2 total)
  • 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 } ?>

    PERFECT! Thank you, Giant Octopus. This did exactly what I needed, and for those who come across this page wondering what the heck to do with the above code here it is…

    1. Click on Plugins->Installed Plugins
    2. Find “Re-Send Welcome Email” by By Andreas Baumgartner which you already installed
    3. Click on “Edit” under the plugin name
    4. Be sure you are editing “re-send-welcome-email.php”
    5. Find the line that begins <form method=”POST”>
    6. Replace to the end of that file with the above code
    7. NOTE the two areas above where you can comment/un-comment if you want to pre-check all the users. I set my range from ID = 2 to 999, un-commenting that section and commenting out the section below it.
    8. Save the edit
    9. Click on Users->Re-Send Welcome Email

    Voila. There they all are, pre-checked (or not) waiting for bulk action.

    Thanks again – this saved enormous amounts of time for me.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘bulk option?’ is closed to new replies.