Support » Plugin: Email Users » 502 Timeout Errors with many users

  • Just curious if it’s possible to stop the plugin from looping through all users when loading the Send to Groups screen. We have 5000+ users and just want to send to a small group of them using the ITThinx Groups integration but it seems that in order to build the page the plugin is looping through all users when it might be able to get away with just querying users based on a group selection when send is hit.

    I would love to help if you can point me in the right direction. I would also be happy to pay you for this modification so we can continue using this helpful plugin!

    • This topic was modified 3 years, 4 months ago by info2grow.
Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter info2grow


    so far I’ve narrowed it to integration/itthinx-groups.php line 87

    // Make sure the list of IDs accounts for the Email Users settings for email
    $ids = mailusers_get_recipients_from_ids($ids, $exclude_id, $meta_filter) ;

    If I comment out that line the send to groups page loads…

    Thread Starter info2grow


    Digging deeper it’s actually with get_users is called in email_users.php on line 1436 that is actually stopping the initial page load of Send to Group(s). Obviously that needs to be there but does it need to happen on page load specifically for send to groups?

    To be clear when either of these lines are not commented out the send to groups page will not load at all and I get a 502. It looks like the code may be looping through all groups and assigning the associated ids of users in each those groups on page load. Perhaps we can just query users of the chosen groups after Send Email is pressed?

    Plugin Author Mike Walsh


    I apologize for the delayed response. I am out of the country this week on vacation and have nothing but an iPad with me so looking at this issue is a challenge.

    5000 users is a lot so it doesn’t surprise me you are seeing a problem. A number of years ago I had a similar problem with Send to Users with someone who had 8000+ users on the site. The solution was to break the query up into chunks. I cannot recall it I ever added the same solution to groups or not, based on your description I am guessing I did not.

    I won’t be back in the US until Sunday and I suspect catching up on work email will take me a day or two. I will try to look into this next week when I am home. If you find a solution and want to send me a patch, I’d be happy to consider incorporating it.

    Thread Starter info2grow


    Thanks Mike! I think I have it sorted…

    in mail-users/integration/itthinx-groups.php

    It looks like it was the code that checks for empty groups.

    In function mailusers_get_itthinx_groups

    1. comment out line 52 as we are already getting the ids on send
    2. Remove the if clause from line 54 that checks for empty groups
    3. We still need a check for empty groups inside function mailusers_get_recipients_from_itthinx_groups_group on line 80 so I added another clause. It works but there may be a better way.

      if ((is_array($group) || is_object($group)) && $group->__get('users')) {

    4. then we need to check if the ids array is empty before calling mailusers_get_recipients_from_ids on line 88
          //  Make sure the list of IDs accounts for the Email Users settings for email
          $ids = mailusers_get_recipients_from_ids($ids, $exclude_id, $meta_filter) ;

    Worked for a small group, now I am about to try a group of 750…

    Thread Starter info2grow


    Update no 502 loading the page so the code above addressed that however when sending to 750 users I got 502 partway through. 293 emails were sent successfully.

    We host with WPEngine and use Mailgun (and the Mailgun plugin) to handle the actual sending of the emails.

    in email-users.php I have number set to 100 on line 1353 if that helps

    //  Set up the arguments for get_users()
        $args = array_merge($args, array(
            'exclude' => array($exclude_id),
            //'fields' => array('ID', 'display_name', 'user_email'),
            'fields' => 'all',
            'offset' => '0',
            'number' => '100',
        )) ;
    • This reply was modified 3 years, 4 months ago by info2grow.
    • This reply was modified 3 years, 4 months ago by info2grow.

    @mpwalsh8 Update? I’m having the same issue on my site with 2000+ users. It takes a good 1 minute before it loads the page. I’m fearing if this continues It will stop working altogether.

    What about adding custom filters to loops by installing respective plugins or setting the group parameter? Though, this can be only a temporary solution.

    Plugin Author Mike Walsh


    As evidence by my lack of response to these questions, I have not really had any time to look into these problem reports. A lot of things have changed for me which really limits how much (little? none?) time I can devote to this plugin (and others too).

    I used WordPress extensively for a number of projects I volunteered on (school, sports, etc.) but with my kids all out of High School, I am not doing that any longer. All of those projects have been handed over to the next group of parent volunteers, some stuck with WordPress, some went other directions. My regular day job, the one which pays the bills, has also changed dramatically in the past couple years as well. I am busier and traveling much more and I don’t expect that to change any time soon.

    If someone is interested in taking over development and maintenance of Email Users, let me know and we can figure something out. I am not the original author, I picked up responsibility in much the same way from the original author who found themselves in a similar situation I find myself in now.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘502 Timeout Errors with many users’ is closed to new replies.