Making cbnet Multi Author Comment Notification 1.1.2 WordPress multisite aware

multisite multi author notification

You don’t need this fix any more, the latest version works with multi site.

2.0 WARNING: Old settings will not be retained
Changelog

Here’s a quick fix (test it before deploying to production) that lets you use the cbnet Multi Author Comment Notification 1.1.2 plugin in a WordPress multisite environment:

Replace:

$user_array = array();
$query = "SELECT ID FROM $wpdb->users";
$result = $wpdb->get_results($query, ARRAY_A);
foreach ( (array)$result as $key=>$row ) {
$data = get_userdata($row['ID']);
$data->wp_user_level = intval($data->wp_user_level);
$userid = $data->ID;
$username = $data->user_login;
$fullname = $data->first_name.' '.$data->last_name;
$email = $data->user_email;
$level = @key($data->wp_capabilities);
$user_array[$data->wp_user_level][] = array($userid, $username, $fullname, $email, $level);
}

With:

$user_array = array();
$get_users_args = array(
'blog_id' => get_current_blog_id()
);
$current_blog_base_prefix = (is_multisite()) ? $wpdb->base_prefix . get_current_blog_id() . '_' : $wpdb->base_prefix;
$result = get_users($get_users_args);
foreach ($result as $row) {
$data = get_userdata($row->ID);
$data->wp_user_level = intval(get_user_meta($row->ID, $current_blog_base_prefix . 'user_level',true));
$userid = $data->ID;
$username = $data->user_login;
$fullname = $data->first_name.' '.$data->last_name;
$email = $data->user_email;
$level = @key(get_user_meta($row->ID, $current_blog_base_prefix . 'capabilities',true));
$user_array[$data->wp_user_level][] = array($userid, $username, $fullname, $email, $level);
}

Provided as-is, aka not supported (yet)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">