Email Users Wordpress Plugin - Rating, Reviews, Demo & Download

Email Users Preview Wordpress Plugin - Rating, Reviews, Demo & Download
4.6 Average out of 28 ratings
Free
Follow for free plugins, new theme releases and theme news

Plugin Description

A plugin for WordPress which allows you to send an email to the registered blog users. Users can send personal emails to each other. Power users can email groups of users and even notify group of users of posts.

Other

All the instructions for installation, the support forums, a FAQ, etc. can be found on the plugin home page or on the plugin overview page.

Translation

Email Users has language translation support for a number of languages. New languages and updates to existing languages are always welcome. Thank you to the people who have provided these translations.

  1. Spanish (es_ES) – Pon? J. Llaneras (last updated: 4.6.3)
  2. Bulgarian (sr_RS) – Borisa Djuraskovic (last update 4.6.2)
  3. Italian (it_IT) – ? (last updated 4.5.1)
  4. German (de_DE) – Tobias Bechtold (last updated 4.4.1)
  5. Persian (fa_IR) – ? (last updated 4.3.6)
  6. French (fr_FR) – Emilie DCCLXI (last updated 4.3.6)
  7. Russian (ru_RU) – ? (last updated 4.3.8)
  8. Chinese (zh_CN) – ? (last updated 4.5.1)
  9. Dutch (nl_NL) – Bart van Strien (last updated 4.6.3)

License

This plugin is available under the GPL license, which means that it’s free. If you use it for a commercial web site, if you appreciate my efforts or if you want to encourage me to develop and maintain it, please consider making a donation using Paypal, a secured payment solution. You just need to click the donate button on the the plugin overview page and follow the instructions.

Filters and Actions

Email Users supports a number of filters and actions.
1. Action: mailusers_before_wp_mail – called before wp_mail is called.
1. Action: mailusers_after_wp_mail – called after wp_mail is called.
1. Filter: mailusers_manipulate_headers – called before wp_mail is called.

This example shows how the mailusers_manipulate_headers filter can be used to change the headers to be compatible with wpMandrill. This code could/would be placed in your functions.php file.

/**
 * wpMandrill needs the recipients in the TO header instead
 * of the BCC header which Email Users uses by default.  This
 * filter will move all of the recipients from the BCC header
 * into the TO header and clean up any formatting and then nuke
 * the BCC header.
 *
 */
function mailusers_mandrill_headers($to, $headers, $bcc)
{
    //  Copy the BCC headers to the TO header without the "Bcc:" prefix
    $to = preg_replace('/^Bcc:s+/', '', $bcc) ;

    //  Empty out the BCC header
    $bcc = array() ;

    return array($to, $headers, $bcc) ;
}

add_filter('mailusers_manipulate_headers', 'mailusers_mandrill_headers', 10, 3) ;

Custom Filter Usage

Email Users provides the ability to send email to a very specific set of users using a custom meta filter. To create a special mail list, you will need to add something similar to the following to your theme’s functions.php file or create a separate plugin file.

The mailusers_register_user_custom_meta_filter() and mailusers_register_group_custom_meta_filter() actions each take 3-4 parameters:
1. Label – text that will appear on the WordPress Email-Users menu (users) or in the Recipient List (groups).
1. Meta Key – the meta key to search for in the user meta table.
1. Meta Value – the value to match against in the user meta table.
1. Meta Compare – optional, defaults to ‘=’. The type of comparison to be performed.

This example will filter the user list to only those users where the first name is Alex.

add_action( 'mailusers_user_custom_meta_filter', 'first_name_alex', 5 );

function first_name_alex()
{
    mailusers_register_user_custom_meta_filter('First Name: Alex', 'first_name', 'Alex');
}

Regular SQL comparisons (=, !=, etc.) can be performed. Wildcard matches (LIKE, NOT LIKE) are not supported due to how the WordPress get_users() API currently handles LIKE comparison. A better solution is to use the REGEXP/NOT REGEXP constructs added in WordPress 3.7. Regular Expressions allow you to select groups of users based on matching meta values like first or last name or ranges within them.

add_action( 'mailusers_user_custom_meta_filter', 'first_names_starting_with_anything_but_d', 5 );

function first_names_starting_with_anything_but_d()
{
    mailusers_register_user_custom_meta_filter('First Name: Not D', 'first_name', '^D', 'NOT REGEXP');
}

add_action( 'mailusers_user_custom_meta_filter', 'last_names_starting_with_m', 5 );

function last_names_starting_with_m()
{
    mailusers_register_user_custom_meta_filter('Last Name: M', 'last_name', '^M', 'REGEXP');
}

add_action( 'mailusers_user_custom_meta_filter', 'last_names_starting_with_s_through_z', 5 );

function last_names_starting_with_s_through_z()
{
    mailusers_register_user_custom_meta_filter('Last Name: Z', 'last_name', '^[S-Z]', 'REGEXP');
}

In addition to filtering on User Meta data to build a custom list of users, you can now define custom groups based on User Meta data.

add_action( 'mailusers_group_custom_meta_filter', 'send_to_fire_department', 5 );

function send_to_fire_department()
{
    mailusers_register_group_custom_meta_filter('Fire Department', 'department', 'fire');
}


add_action( 'mailusers_group_custom_meta_filter', 'send_to_police_department', 5 );

function send_to_police_department()
{
    mailusers_register_group_custom_meta_filter('Police Department', 'department', 'police');
}

In addition to defining specific Meta Key and Value pairs, Email Users also supports a filter to generate the Meta Group filters based on a Meta Key. The Meta Key filter supports two optional arguments – a Meta Value and a function callback to generate the label. Neither is required. When the label callback is used, it receives two arguments, both strings, the Meta Key and Meta Value. It must return a string.

//  Define action to send to blog followers
add_action( 'mailusers_group_custom_meta_key_filter', 'send_to_my_blog_followers', 5 );

function send_to_my_blog_followers()
{
    mailusers_register_group_custom_meta_key_filter('blog_follower');
}

function send_to_departments_label($mk, $mv)
{
    return(ucwords($mk) . ' = ' . ucwords($mv)) ;
}

//  Define action to send to departments using custom callback to generate the label
add_action( 'mailusers_group_custom_meta_key_filter', 'send_to_departments', 5 );

function send_to_departments()
{
    mailusers_register_group_custom_meta_key_filter('department', null, 'send_to_departments_label');
}

function send_to_departments_label($mk, $mv)
{
    return(ucwords($mk) . ' = ' . ucwords($mv)) ;
}

New in v4.5.0 is an action, mailusers_update_custom_meta_filters, which can be used to dynamically update Meta Filters before they’re used for recipient selection or email address retrieval. The example below leverages the Meta Key Department and its various values to define and update a new Meta Key called publicworks. Anytime a Group Email is sent or Post/Page notification is initiated, this action will fire and rebuild the publicworks meta key based on the values of the department meta key. This sort of action could be used to create more complex meta value relationships or to integrate other plugins.

add_action( 'mailusers_group_custom_meta_filter', 'send_to_public_works', 5 );

function send_to_public_works()
{
    mailusers_register_group_custom_meta_filter('Public Works', 'publicworks', true);
}

add_action( 'mailusers_update_custom_meta_filters', 'update_publicworks_meta_filter', 5 );

function update_publicworks_meta_filter()
{
    $pw_mk = 'publicworks' ;
    $dept_mk = 'department' ;

    //  Define the valid matches - the array keys match user
    //  meta keys and the array values match the user meta values.
    //
    //  The array could contain a mixed set of meta keys and values
    //  in order to group users based on an arbitrary collection of
    //  user meta data.

    $publicworks = array(
        array($dept_mk => 'fire'),
        array($dept_mk => 'police'),
        array($dept_mk => 'water and sewer'),
        array($dept_mk => 'parks and recreation'),
    ) ;

    //  Remove all instances of the Public Works meta key
    //  to account for employees no longer with Public Works
    $uq = new WP_User_Query(array('meta_key' => $pw_mk)) ;

    foreach ($uq->get_results() as $u)
        delete_user_meta($u->ID, $pw_mk) ;

    //  Loop through the departs and select Users accordingly
    foreach  ($publicworks as $pw)
    {
        $uq = new WP_User_Query(array('meta_key' => $dept_mk, 'meta_value' => $pw[$dept_mk])) ;

        //  Loop through the users in the department and tag them as Public Works employees
        foreach ($uq->get_results() as $u)
            update_user_meta($u->ID, $pw_mk, true) ;
    }
}

Screenshots

No screenshots provided


Reviews & Comments