Support » Plugin: Email Users » Custom met filter by role

  • Resolved dsjohnson


    I would like to set up a custom filter by role. something like the following:

    add_action( ‘mailusers_user_custom_meta_filter’, ‘pgc_active_members’, 5 );

    function pgc_active_members()
    mailusers_register_user_custom_meta_filter(‘Active members’, ‘Role’, ‘inactive’, ‘!=’);

    However this returns a blank list.

    Other attempts with built in or custom roles also do not work.

    Thanks for any help.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Mike Walsh


    Sorry for the delayed response to your question. I missed this while I was out of the country for work.

    I am assuming your reference to “role’ is the WordPress definition of role from the WordPress roles and capabilities. If it is not, then the rest of this post probably doesn’t make any sense.

    I don’t have an easy way to look at a WordPress database right now but I don’t think role is stored as user meta data which would explain why you’re not seeing results to the query. The Custom Meta filter is specifically written to use meta data from a user.

    So how would you get around this? You could write a small plugin which runs periodically which processes all of the users in on your site and their roles and stores the value(s) as user meta data. The Email Users meta query would then work based on the field you define to store the role data.

    I set up a custom meta to flag the users I want and I am trying to use your ‘mailusers_group_custom_meta_filter’ and mailusers_register_group_custom_meta_filter

    However they do nothing. I’ve even copied the examples you have posted.

    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’);
    They also do nothing. did something break in an update?

    The mailusers_user_custom_meta_filter works fine but does not allow what I want to do.

    Never mind I think I got it.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom met filter by role’ is closed to new replies.