Increase How Many Members are Scanned for EOT Reminders Per Process?

At line 110 in reminders.inc.php it says, regarding users to scan for EOT Reminders: LIMIT '.esc_sql($per_process).'

And earlier in the document $per_process is set as: $per_process=apply_filters('ws_plugin__s2member_pro_eot_reminders_per_process', $vars['per_process'], get_defined_vars());

I think that all the members in the database are not being scanned for EOT reminders because the per_process number isn’t set high enough.

Is there a way to know what this is and then set or increase it if necessary?

The assumed behavior is that it would run multiple processes until all the users were checked, however it seems to only run once through a limited number of users.

I believe I have now resolved this issue.

When I echoed out $per_process it reported only 6 per process. I’m assuming this means that every time the cron job is fired; it doesn’t continually loop through all users until they have all been checked. As we acquired new members the old ones were ‘pushed’ out of the group that was being processed every day - about 500-600 users. So only that group was being checked for EOT Reminders. Finding members in the database with a last_reminder_scan set from over a year ago was part of the clue.

How to change it was kind of obvious since there is a filter attached to the string: ws_plugin__s2member_pro_eot_reminders_per_process. I increased the number incrementally until in a day it would process every member. This was about 45 per process for our member base, I then set it higher to account for future growth.

Hi @AJD

Would you mind explaining (in simple terms) how you increased this limit? I have many thousands of members and many of my EOT reminders aren’t being sent out either.

I’ve been tempted to try s2emails from @andrejstas but I’m waiting until that can update the emails if the EOT has been changed manually.

Thanks!

Mark

Hi Mark,

No problem, here’s the snippet I added in my functions.php file:

// Increase per process SQL records scanned for EOT Reminder Emails

			add_filter ('ws_plugin__s2member_pro_eot_reminders_per_process', 'aamet_set_eot_per_process');
			
			function aamet_set_eot_per_process(){
				$per_process = 75;
				return $per_process;
				}	

If you would like to see what your current per process # is set to, you can make a temporary edit to the reminders.inc.php file in s2member-pro > src > includes > classes > reminders.inc.php at line 85. Add this : echo "Per Process: " . $per_process ;

Then visit the following URL: yoursite.com/?s2member_auto_eot_system_via_cron=1

(Don’t forget to remove the edits when you are done. )

I had to clear the cache to get this to go.

You probably want to install the WP Mail Log plugin if you haven’t already.

(I also set up a manual cron job to hit that url every 30 minutes so things keep processing when no one is on the site and set s2member in PayPal options EOT Behavior to 'Yes I’ll run it with my own cron job. Here’s the cron: curl -s mysiteurl.com/?s2member_auto_eot_system_via_cron=1 >/dev/null 2>&1)

… and if you want to double verify that your users are being scanned you can go into phpmyadmin in your cPanel and go to the usermeta table for your database, then run a search by clicking ‘Search’ and in the meta_key area change the operator to like % % , and type the value s2member_last_reminder_scan, click go.

You will see a list of all your users that have been scanned at least once with their user id. The metavalue is a unix time stamp which contains the last scan date. Use something like this http://www.convert-unix-time.com/, to quickly convert the date to be readable.

If you click the meta_value heading, it will sort the column so you can then look at the list in reverse order to see which users have the oldest last scan time.

Before making these changes some of my users had a last scan time from over a year ago, and never received an EOT notification. After the changes, every member gets scanned at least once every 24 hours.

Hope that helps.

Best,

AJ

2 Likes

Hi @AJD,

Thank you SO much for these clear instructions. I’ve just gone through them and discovered similar results. My ‘per process’ was set to 6 and there were members who hadn’t been checked since February 2016. The number of results in the usermeta table search was pretty low, so I’m guessing that many members had never been checked.

I’ve used your code in my functions.php table and that’s pushed things forward. I use Postmark for transactional emails and they’re all sending out nicely from there.

Can I ask you came up with the ‘per process’ figure of 45? Setting up a manual cron job is a bit over my head so I’m wondering how often the script is set to run by itself.

Thanks again for your help. I really appreciate it.

Mark

Hi Mark,
Glad it helped.
s2Member attaches it’s ‘to-do list’ to wp-cron. Wp-cron requires that your site has traffic in order to run. I’m not sure how often s2 tells wp-cron that it needs to run through the EOT Reminder scan, or how many times it loops through the $per_process number each time. But let’s say it runs the per_process number once every time wp-cron is triggered, at 6 scans per process wp-cron would need to be triggered 84 times to scan 2000 members.

Since I have a manual cron set for every 30 minutes I divided my total number of users (2000) by 48 - the number of times the cron will run in a 24 hour period. The result is 41.6. (I rounded it up to 45). So, and here’s where I don’t fully understand s2member behavior, if s2member looks at 45 members each time it runs, in 24 hours (45 every half hour) it will have looked at all 2000 members. I’m assuming that it only scans the exact per_process number each time the cron fires, it could be more than that, but at least that is the minimum I know will run through everyone.

Hi AJD,

I hope you’re still monitoring this post.
I have the same issue with EOT notifications for a site I manage. I have implemented your filter but have not put it into Functions.php as the file already existed in my themes directory and I didn’t want to take the chance that the next theme update would kill the change, so I created a must use plugin and placed it there. I can see the plugin via the installed plugins vies so I’m happy that it’s all there and I have checked via the echo “Per Processes…” and it confirms the value I set. Originally it was scanning 6 database members. What I can’t see is that the change has made any difference. What I mean by that, is it should have been initiated yesterday but no evidence via the WP Mail Log plugin, so I’m thinking no chnage.
As the membership’s expire on 30 September, I’m keen to make sure that more than 6 notifications go out to members before they’re all downgraded.

As I am not a coder, I’m seeking your help re your manual cron. I look at it and say that there’s more to the complete cron. I have also looked through a lot of literature re how to write and implement a cron, and it look’s a little different, so I wonder if you would publish the whole cron (start to finish).
Also where would you put it, the documentation I’ve read again refers to the functions.php file, but will that not be overwritten by a theme update as it appears to have a lot of theme related code in it.

Hello Branko,
I use the cron tool in cPanel. If you don’t have cPanel then your hosting should have some kind of cron setup tool. Here’s a help file if you are using Siteground: https://www.siteground.com/tutorials/wordpress/real-cron-job/

Check my post from above about how to check the s2member_last_reminder_scan value in your database. That is the only way I know for sure to know if they have been checked by the EOT system.

If the users have been checked by the EOT system and an email didn’t go out it probably means there isn’t an email reminder setup to go out so I’d check your EOT reminder settings. For example I am using PayPal so the EOT reminders are all setup in the PayPal EOT reminders tab.

1 Like

Hi AJD,
This is weird, I have re-read your earlier post and am also using PayPal EOT reminders.

PayPal EOT settings are:
Automatic EOT Behavior = Yes (enable the Auto-EOT system through WP-cron)
EOT Renewal/Reminder Emails = Yes (enable)
Remind X Days before… = -30, -14, -5, -4, -3, -2, -1 (the -4, -3, -2 I added yesterday as I could not see any evidence of emails going out).

I have also checked and all members that are still un-financial their EOT date is set to 09/30/2020 UTC.

The last email sent out was on 09/24/2020 UTC. This was verified via the S2Member eot-reminders.log file and WP Mail Log plugin.

I have checked the s2member_last_reminder_scan and all records have been scanned between the 26th and 27th.

I have found the cPanel cron tool which looks like the image below. I assume your cron would be added into the Command line. I assume that your cron forces a scan of members. This appears to be working but the email is not being sent. Any thoughts, there must be something else that’s stopping the email from being sent.
I need to add that the -30 and -5 emails were sent but only for about a quarter of members.

I would really appreciate anything that you could think of.

Hi,
Yes the cron gets added to Command. You could ask your hosting for help as well.

As far as the emails still not going out it could be that your users haven’t been all scanned after you setup your new .4, -3, -2, -1 emails. If you want to be sure, set your your per-process number to 2000 or something like that and manually visit this url: mysiteurl.com/?s2member_auto_eot_system_via_cron=1

Manually hitting that URL should trigger your EOT system scan and if you have your per-process number set very high it should scan everyone in one go, if it doesn’t you can visit the url again. Just be sure that your host doesn’t have a limit on your email sending capacity.

If that doesn’t trigger all your emails to go our I’d look into error logs and see if something else is happening.

1 Like

Hi AJD,
Yes I have done all that, the per-process setting is well above the number of members and the scanning appears to be OK and I have checked the scan dates and they are all happening daily.
Today it send out 9 emails for the -1 trigger.

I don’t think the host is an issue as we’re only taking about 200 members but will check.
The other strange thing I uncovered today is the email being send out is not the email per the EOT Renewal/Reminder email(s) message. The email sent out:

and the email text per the setting that should be used.

So where is the email text from. I have scanned all the PayPal settings options and while they look similar I can not find what it is sending out.
Something definitely strange going on.

Hi AJD,

Well today S2 sent out some 90 emails using the -1 trigger which happen to be the remaining un-financial members but still using the email message that is not consistent with the EOT Renewal/Reminder Message settings.

This leads me to conclude that the reminder “X days before EOT Occurs” and the message are stored somewhere behind the scenes and S2 is ignoring those settings on the “EOT Renewal/Reminder Emails” page. Which could be that the Save All Changes button is actually not overwriting previous settings.

Any thoughts.

It sounds like you looked at each message for each trigger, so I’m not sure. You could try searching your database for that text and see where it is set.