latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Need help setting up EOT notification

Home Forums Community Forum Unofficial Extensions/Hacks Need help setting up EOT notification

This topic contains 9 replies, has 4 voices. Last updated by  Danny Kim 3 years, 5 months ago.

Topic Author Topic
Posted: Sunday Nov 11th, 2012 at 8:32 pm #31267
Danny Kim
Username: dannyk1m

I went off of Bill’s EOT Notification post (http://www.s2member.com/forums/topic/setting-up-eot-notifications/)

But im noob when it comes to PHP and could use some assistance setting it up.
I created the /wp-content/mu-plugins directory with the s2hack_eot_notify.php file.

and in this s2hack_eot_notify.php file i have the following code..

ID, $wpdb->prefix.'s2member_auto_eot_time', true)) && !($neot = get_user_meta($current_user->ID, 's2_eot_notify_date', true))):
			$neot = $eot - $time_to_sub;
			/**/
			if($neot > time()) # If the Notification EOT time is in the future
				add_user_meta($current_user->ID, 's2_eot_notify_date', $neot); # Add the Notification EOT time
		endif;
		if(!wp_next_scheduled('s2hack_eot_notify') && $GLOBALS['WS_PLUGIN__']['s2member']['o']['auto_eot_system_enabled'])
			wp_schedule_event(current_time('timestamp'), 'daily', 's2hack_eot_notify');
	}
	
if(has_action('s2hack_eot_notify')) # Add action only if it exists
	add_action('s2hack_eot_notify', 's2hack_eot_notification');
function s2hack_eot_notification() # Function to be called daily
	{
		$n_eot = time();
		/**/
		if(is_array($eots = $wpdb->get_results("SELECT `user_id` AS `ID` FROM `".$wpdb->usermeta."` WHERE `meta_key` = 's2_eot_notify_date' AND `meta_value` != '' AND `meta_value` escape($n_eot)."' LIMIT 3"))):
			foreach($eots as $eot): # We need to loop through all of the IDs to send the data
				if(($user_id = $eot->ID) && is_object($user = new WP_User($user_id)) && $user->ID && !$user->has_cap('administrator')): # Set up variables
					delete_user_meta($user_id, 's2_eot_notify_date');
					$to = $user_email;
					$subject = 'Notification of membership renewal!';
					$message = "Dear, $user_id. nn Your membership with Suzuki Music Los Angeles is due for renewal. n Please login at suzukimusiclosangeles.com and submit your payment to extend your membership. nn Thank you! n Suzuki Music Los Angeles";
					$headers = 'From: SMAC-LA ' . "rn";
					function wp_mail( $to, $subject, $message, $headers ){};
				endif;
			endforeach;
		endif;
	}

?>

Will this work or did I do anything wrong or should I fix/change something?
Could use a PHP experts advice here..

List Of Topic Replies

Viewing 9 replies - 1 through 9 (of 9 total)
Author Replies
Author Replies
Posted: Tuesday Nov 13th, 2012 at 1:57 pm #31467
Danny Kim
Username: dannyk1m

..anybody? could really use some help with this.

Posted: Tuesday Nov 13th, 2012 at 7:04 pm #31504
Eduan
Username: Eduan
Moderator

Hello Danny,

I haven’t played around with this myself, so I’m not sure if it would work, but if you followed Bruce’s instructions correctly then there shouldn’t be any problem. :)

BTW, you can freely test this in your website, since this can easily be fixed if it messes something up, which again, if you followed Bruce’s instructions correctly, it shouldn’t be any problem.

– Eduan

Posted: Wednesday Nov 14th, 2012 at 11:59 am #31587
Danny Kim
Username: dannyk1m

Hi Eduan.
Thanks for your feedback!
The part I’m worried about is toward the end about the wp_mail function. Im not sure if I did that correctly.

Also, this is going on a client’s website so I want to make sure the coding is atleast double checked before I upload it.

Posted: Wednesday Nov 14th, 2012 at 7:42 pm #31634
Eduan
Username: Eduan
Moderator

Seems to be correct… I did notice an error with your mail function, change:

function wp_mail( $to, $subject, $message, $headers ){};

to:

wp_mail( $to, $subject, $message, $headers );

Otherwise you will be defining the function, instead of using it.

See if that works. BTW, I suggest you have a test website if you’re gonna be making tests, otherwise it’s gonna be hard to know if it works or not. :)

– Eduan

Posted: Friday Jan 4th, 2013 at 8:51 pm #36200

danny, did your code work?

I’m looking for a solution as well for this implausibly-not-existent feature to notify subscribers of their upcoming renewal.

thanks

Posted: Monday Jan 7th, 2013 at 4:26 pm #36484
Danny Kim
Username: dannyk1m

I haven’t been able to test it myself.
I will do so shortly and let you know!

Posted: Friday Mar 22nd, 2013 at 1:16 am #45442

Danny, Please update here if the code works fine. Even I have done the same, just wanna confirm. I have some other issues with my payment setup, so I cannot run this for test.

Thanks

Posted: Monday Jul 22nd, 2013 at 4:16 pm #53824
Danny Kim
Username: dannyk1m

The test hasn’t worked for me.
I set the EOT date to tomorrow at 1pm. Did the notification for 24 hours earlier..
Never got an e-mail.

Any suggestions?

Also, my client wants to send a notice three times, 30 days apart starting from EOT date. This possible?

Posted: Monday Jul 22nd, 2013 at 6:29 pm #53829
Danny Kim
Username: dannyk1m

ok so I couldn’t get Bill’s EOT Notice hack to work for me..so instead i tried:
EOT Email notification (temporary solution)

This worked for me. Also used the ‘get key’ method for a little security.
Worked and got the e-mail to send right on EOT…but now I need 2-3 more notices sent in 30 day increments.
THIS one, I will need help with.

Using the EOT/Deletion Notice API in s2member, apparently you can add multiple notification URLs?
Wouldn’t this be possible to just use the same file and have the system send a notification like this..
EOT Notice, +30 days, +60 days, +90 days?

Anybody? Could really use some help here. Thanks.

EDIT
Doing some research and asking around, most of my responses were to plugin a cron event.
i installed WP Crontrol and could use some help on how to setup this +30, +60, +90 day notification.
Here’s a summary of whats going on..
My client wanted to set the EOT date to be July 31st. (done)
Assuming the ‘current date’ is after July 31st, I need the cron to check if a user’s EOT is still the current year.(if the user has already renewed their membership, the EOT year would have been change to the following year.)
If it is still the current year(and after July 31st) then if it’s 30, 60, or 90 days after the EOT date to send a membership renewal e-mail to the user.

Viewing 9 replies - 1 through 9 (of 9 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.