Quantcast
Channel: AJ Designs
Viewing all articles
Browse latest Browse all 69

Fix S2member Pro EOT Reminder Emails not Being Sent when You Have a Large User Base

$
0
0

 I had a pretty serious problem with s2Member  EOT reminders not being sent

on a website with a large user base, about 2000. This was resulting in potentially a large loss of member renewals. The strange thing was that many of the EOT reminders were going out, so it made me lax in checking if ALL of them were going out. After digging into the code and the database I found that s2Member scans the users and adds a marker for when they were last scanned. This will only work to send emails reliably  if every user is scanned every 24 hours. However it looked like only about 1/4 of the users had a scan time set within the last 24 hours and many of them had a last scan time of 6 months to over a year ago! These users were often expired and had never received any EOT notification. 

From my original posts on the s2Member forum:

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.

Found a Solution:

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 turned out to be kind of obvious since there is a filter available: 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 the member base, I then set it higher to account for future growth.

Here’s the code to set the per-process scans which fixes the EOT Reminders:

…Added in functions.php file:

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

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

More Detail

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 ;

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

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

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

(I also set a manual cron job to hit that url every 30 minutes 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)

I’d also highly recommend to install the WP Mail Log plugin to monitor the emails. (During troubleshooting I created a spreadsheet of all the users and checked them off as the EOT Reminders were sent so I could see if anyone was missed.)

… and if you want to double verify that your users are being scanned by s2Member, 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 users had a last scan time from over a year ago, and never received an EOT notification.

Another thing to consider is setting up the EOT reminder notifications to communicate to users who may have expired but did not know it and never received notification. Since fixing this I have seen a steady uptick in users who are resubscribing.

The post Fix S2member Pro EOT Reminder Emails not Being Sent when You Have a Large User Base appeared first on Aaron Jerad Designs.


Viewing all articles
Browse latest Browse all 69

Trending Articles