Email Users Custom Lists

A recent question on the WordPress Support forum got me thinking on how to solve this user’s question.  The obvious answer was to use the Custom Meta filter capability which has been part of Email Users for quite a while.

The one limitation of Custom Meta filters was the limitation in how WordPress support SQL wildcards in the LIKE and NOT LIKE constructs.  WordPress would add unwanted escape characters preventing the wildcard from matching rendering LIKE and NOT LIKE largely useless.  I had submitted a WordPress patch 4+ years ago when I ran into this issue and expected it to be fixed in WordPress 3.6.  It was never incorporated, I am not sure why, there isn’t much of an explanation in the ticket.

When I started looking back into this today I found that WordPress had added support for regular expressions (REGEXP, NOT REGEXP) to user meta queries.  This is good news as it is actually a better, and easier to use, solution than using the SQL LIKE construct.

I have updated Email Users to reflect this recommended usage, all of the examples have switched from LIKE to REGEXP and I’ve added a couple more.  I’ve also updated the example plugin I use to test these custom meta queries.  I prefer to put these type of things in a small plugin instead of the theme’s functions.php file because risk of losing them with a theme update or change is much lower.

Email Users Custom List (5595 downloads )

 

Example:  Select Users with Last Name beginning with M:

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');
}

Example:  Select Users with Last Names beginning with S-Z:

</pre>
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: S-Z', 'last_name', '^[S-Z]', 'REGEXP');
}
<pre>

3 thoughts on “Email Users Custom Lists

  1. Hi Mike, I’m having an issue with this plugin and can’t see a fix.

    Upon form submission I get the following message:

    “cURL error 28: Operation timed out after 1001 milliseconds with 0 bytes received

    Unable to retrieve Google Form. Please try reloading this page.”

    Any ideas? my form url is http://footballpredictions.eu/wpgforms/191/

    • I can’t look at your site here at work (our firewall blocks it) so I will have to guess … the message you are seeing comes from the fact that the plugin has made a request to Google’s server and Google’s server hasn’t responded in a timely fashion. You can increase the cURL timeout to see if it addresses the problem. There is a setting on the Settings Page (Dashboard > Google Forms > Advanced Tab) to increase the cURL timeout.

  2. I think this is a shorter and better way to say it:

    Select multiple users by pressing the CTRL key. Users who have elected to not receive mass emails will be filtered out.

Leave a Reply to Mike WalshCancel reply