mass emailer

when i install the mass emailer,under my profile it list recieve admin emails but the selection box is empty.

in the admin section (where you write the mails) it says 380 out of 210 user(s) currently accepting emails.

how can 380 out of 210 user be accepting emails?

  • djtheropy
    • Design Lord, Child of Thor

    not that i noticed.

    i unistalled it (deleted table and file)

    re-uploaded it, created the tables from fresh and now the table wp_mass_mailer only has 1 entry.

    admin panel now says

    Send an email to blog owners. 1 out of 201 user(s) currently accepting emails.

  • bschwarting
    • Flash Drive

    I’m getting something similar. Under the profile, “Receive Admin Emails:” the drop down box doesn’t have any options.

    When new users sign up, they get the same thing, so all users won’t receive the admin emails.

    1 out of 6 user(s) currently accepting emails. (new site)

    FYI, “Recieve” is spelled wrong :slight_smile:

  • djtheropy
    • Design Lord, Child of Thor

    ive noticed if you un-install , remove tables from the db and then re-install, it will say 0 out of x users accepting mail, however when a new blog is registered it changes to 1 out of x.

    in short when it installs it does not add tables in the db for already existing blogs and only creates them for newly created ones.

  • aahinoam
    • New Recruit

    I had the same problem (selection box is empty in the user profile page). After debugging for a while here are my findings:

    There are two bugs the code, which cause the ‘recieve_admin_emails’ to be never set in the usermeta table. The first time the mass_mailer_user_install function is being called, the $current_user is not set and therefore the function mass_mailer_global_db_sync fails to set the user recieve_admin_emails value. The second bug is in the mass_mailer_global_db_sync itself, which tries to set the email_optout value in the wp_mass_mailer table based on the recieve_admin_emails value which was never set…

    the following fix these bugs and also install and update all users’ data in the same time (which means that the mass_mailer_user_install is now useless):

    1. Delete the following lines:

    if ($_GET == ‘mass_mailer_main’:wink:{

    mass_mailer_install();

    mass_mailer_upgrade();

    }

    if (get_site_option( “mass_mailer_installed” ) == “yes”:wink: {

    mass_mailer_user_install();

    }

    2. Add the following line:

    add_action(‘load-site-admin_page_mass_mailer_main’, ‘mass_mailer_install’:wink:;

    3. Replace the processArrayUsersPopulate function with the following updated version:

    function processArrayUsersPopulate($arrayName) {

    global $wpdb, $wp_roles, $current_user, $user_ID;

    foreach ($arrayName as $arrayElement) {

    if (count($arrayElement) > 1) {

    processArrayUsersPopulate($arrayElement);

    } else {

    $intArrayCount = $intArrayCount + 1;

    if ($intArrayCount == 1) {

    $tmp_email_count = $wpdb->get_var(“SELECT COUNT(*) FROM wp_mass_mailer WHERE email_user_id = ‘” . $arrayElement . “‘”:wink:;

    if ($tmp_email_count == ‘0’:wink: {

    $tmp_email_count2 = $wpdb->get_var(“SELECT COUNT(*) FROM wp_usermeta WHERE user_id = ‘” . $arrayElement . “‘ AND meta_key = ‘recieve_admin_emails'”:wink:;

    if ($tmp_email_count2 == ‘0’:wink: {

    update_usermeta($arrayElement, ‘recieve_admin_emails’, ‘yes’:wink:;

    $wpdb->query( “INSERT INTO wp_mass_mailer (email_user_id, email_optout, email_status) VALUES ( ‘” . $arrayElement . “‘, ‘yes’, ‘yes’ )” );

    } else {

    $wpdb->query( “INSERT INTO wp_mass_mailer (email_user_id, email_optout, email_status) VALUES ( ‘” . $arrayElement . “‘, ‘” . get_usermeta($arrayElement, ‘recieve_admin_emails’:wink: . “‘, ‘yes’ )” );

    }

    } else {

    $recieve_admin_emails = get_usermeta($arrayElement, ‘recieve_admin_emails’:wink:;

    if(!$recieve_admin_emails) {

    $recieve_admin_emails = ‘yes’;

    update_usermeta($arrayElement, ‘recieve_admin_emails’, $recieve_admin_emails);

    }

    $wpdb->query( “UPDATE wp_mass_mailer SET email_optout = ‘” . $recieve_admin_emails . “‘ WHERE email_user_id = ‘” . $arrayElementc . “‘” );

    }

    }

    if ($intArrayCount == 2) {

    //echo “<td valign=’top’>$arrayElement</td>”;

    }

    }

    }

    }

    4. Update the mass_mailer_global_db_sync function to the following:

    function mass_mailer_global_db_sync() {

    global $wpdb, $wp_roles, $current_user;

    $tmp_email_count = $wpdb->get_var(“SELECT COUNT(*) FROM wp_mass_mailer WHERE email_user_id = ‘” . $current_user->ID . “‘”:wink:;

    if ($tmp_email_count == ‘0’:wink: {

    $wpdb->query( “INSERT INTO wp_mass_mailer (email_user_id, email_optout, email_status) VALUES ( ‘” . $current_user->ID . “‘, ‘yes’, ‘yes’ )” );

    } else {

    $recieve_admin_emails = get_usermeta($current_user->ID, ‘recieve_admin_emails’:wink:;

    if(!$recieve_admin_emails) {

    $recieve_admin_emails = ‘yes’;

    update_usermeta($current_user->ID, ‘recieve_admin_emails’, $recieve_admin_emails);

    }

    $wpdb->query( “UPDATE wp_mass_mailer SET email_optout = ‘” . $recieve_admin_emails . “‘ WHERE email_user_id = ‘” . $current_user->ID . “‘” );

    }

    }

    Hope it will get into the official version.

    Cheers,

    Amir

  • aahinoam
    • New Recruit

    More:

    In order to support new users the following function should be updated to:

    function mass_mailer_global_db_sync() {

    global $wpdb, $wp_roles, $current_user;

    $tmp_email_count = $wpdb->get_var(“SELECT COUNT(*) FROM wp_mass_mailer WHERE email_user_id = ‘” . $current_user->ID . “‘”:wink:;

    if ($tmp_email_count == ‘0’:wink: {

    $wpdb->query( “INSERT INTO wp_mass_mailer (email_user_id, email_optout, email_status) VALUES ( ‘” . $current_user->ID . “‘, ‘yes’, ‘yes’ )” );

    update_usermeta($current_user->ID, ‘recieve_admin_emails’, ‘yes’:wink:;

    } else {

    $recieve_admin_emails = get_usermeta($current_user->ID, ‘recieve_admin_emails’:wink:;

    if(!$recieve_admin_emails) {

    $recieve_admin_emails = ‘yes’;

    update_usermeta($current_user->ID, ‘recieve_admin_emails’, $recieve_admin_emails);

    }

    $wpdb->query( “UPDATE wp_mass_mailer SET email_optout = ‘” . $recieve_admin_emails . “‘ WHERE email_user_id = ‘” . $current_user->ID . “‘” );

    }

    }

    and one more thing, users that are deleted from the site are not removed from the wp_mass_mailer table .

    Amir

  • aahinoam
    • New Recruit

    The following lines will add the support for deleted users:

    add_action(‘wpmu_delete_user’, ‘mass_mailer_delete_user’:wink:;

    function mass_mailer_delete_user($deletedUserID) {

    global $wpdb;

    $query = “DELETE FROM wp_mass_mailer WHERE email_user_id = ‘$deletedUserID’;”;

    $wpdb->query( $query );

    }

    Amir