Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Mass email function

I have a custom plugin for that. Here are the two important functions:

function bb_mail_users($subject, $content) {
global $bbdb;
$users = $bbdb->get_results("SELECT ID, user_login, user_email FROM $bbdb->users");
foreach ($users as $user)
bb_mail_user($user->ID, $user->user_login, $user->user_email, $subject, $content);
}

function bb_mail_user($user_id, $user_login, $user_email, $subject, $message) {
$message = str_replace('%user_login%', $user_login, $message);
$message = str_replace('%user_id%', $user_id, $message);
$message = str_replace('%user_email%', $user_email, $message);

$subject = str_replace('%user_login%', $user_login, $subject);
$subject = str_replace('%user_id%', $user_id, $subject);
$subject = str_replace('%user_email%', $user_email, $subject);

bb_mail($user_email, $subject, $message);
}

I think it’s pretty straightforward. You can write a message like: “Hello, %user_login%, how are you? Thanks for participating in this forum :)” and a subject like “Thanks, %user_login%”. Then, to mail that to all your users:

$content = "Hello, %user_login%, how are you? Thanks for participating in this forum :)";
$subject = "Thanks, %user_login%";
bb_mail_users($subject, $content);

Skip to toolbar