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.

Home Forums chidu

About: chidu

Sorry, I've not written a description yet. I'll get to it soon!


Topics I'm Subscribed To

Viewing topic 1 (of 1 total)
Topic Count Last Reply
EMail for Renewal of Membership

By:  chidu in: Community Forum

voices: 3
replies: 6

4 years, 2 months ago  chidu

Viewing topic 1 (of 1 total)

Topics I've Started

Viewing topic 1 (of 1 total)
Topic Count Last Reply
EMail for Renewal of Membership

By:  chidu in: Community Forum

voices: 3
replies: 6

4 years, 2 months ago  chidu

Viewing topic 1 (of 1 total)

My Latest Replies (From Various Topics)

Viewing 3 replies - 1 through 3 (of 3 total)
Author Replies
Author Replies
Posted: Tuesday Nov 6th, 2012 at 4:21 am #30754
chidu
Username: chidu

Hi Cristian,

I have written the code, can you pls check the code and tell me tat it’s work properly or not.

<?php
$conn = mysql_connect('localhost', 'root', '');
$database = mysql_select_db('datetime',$conn);
?>
<?php

date_default_timezone_set("UTC");

//Function to Calculate the time difference
function dateDiff($time1, $time2, $precision = 6) {
	// If not numeric then convert texts to unix timestamps
	if (!is_int($time1)) {
	  $time1 = strtotime($time1);
	}
	if (!is_int($time2)) {
	  $time2 = strtotime($time2);
	}
	
	// If time1 is bigger than time2
	// Then swap time1 and time2
	if ($time1 > $time2) {
	  $ttime = $time1;
	  $time1 = $time2;
	  $time2 = $ttime;
	}
	
	// Set up intervals and diffs arrays
	$intervals = array('year','month','day','hour','minute','second');
	$diffs = array();
	
	// Loop thru all intervals
	foreach ($intervals as $interval) {
	  // Set default diff to 0
	  $diffs[$interval] = 0;
	  // Create temp time from time1 and interval
	  $ttime = strtotime("+1 " . $interval, $time1);
	  // Loop until temp time is smaller than time2
	  while ($time2 >= $ttime) {
	$time1 = $ttime;
	$diffs[$interval]++;
	// Create new temp time from time1 and interval
	$ttime = strtotime("+1 " . $interval, $time1);
	  }
	}
	
	$count = 0;
	$times = array();
	// Loop thru all diffs
	foreach ($diffs as $interval => $value) {
	  // Break if we have needed precission
	  if ($count >= $precision) {
	break;
	  }
	  // Add value and interval 
	  // if value is bigger than 0
	  if ($value > 0) {
	// Add s if value is not 1
	if ($value != 1) {
	  $interval .= "s";
	}
	// Add value and interval to times array
	$times[] = $value . " " . $interval;
	$count++;
	  }
	}
	
	// Return string with times
	return implode(", ", $times);
}

//Function to Send mail
function sendmail($to, $remaindays){
	$tomail	 = $to;
	$from    = "abc@abc.com";	 
	$semi_rand = md5(time());
	$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
	
	//$headers  = "MIME-Version: 1.0\r\n";
	//$headers .= "Content-type: text/html; charset=UTF-8\r\n";	
	$mailSubject = "Bones of PA : Mail Regarding Renewal of the Membership";
	$headers = "From: $from";
	$headers .= "\nMIME-Version: 1.0\n" .
				  "Content-Type: multipart/mixed;\n" .
				  " boundary=\"{$mime_boundary}\"";			
		
	$message = "This mail is regarding to inform that your membership is going to be expired ".$remaindays.", so please renew the Membership soon ";
	$message = "This is a multi-part message in MIME format.\n\n" .
				 "--{$mime_boundary}\n" .
				 "Content-Type: text/html; charset=\"UTF-8\"\n" .
				 "Content-Transfer-Encoding: 7bit\n\n" .
				 $message . "\n\n";
	$ok = @mail($tomail, $mailSubject, $message, $headers);	

}
?>

<?php
$date1 = date( "Y-m-d", time() );
$date2 = "2018-10-23";

$sql = 'SELECT * FROM mem_users';
$qury = mysql_query($sql);

while($row = mysql_fetch_array($qury)){
	$mailid = $row['user_email'];
	$date_time = $row['user_registered'];
	$date = split(' ', $date_time);//echo $date[0]."<br>";
	$date2 = $date[0];

	$day = dateDiff($date2, $date1);
	$noofdays = explode(", ", $day);
	//print_r($noofdays);
	$years = $noofdays[0];
	$months = $noofdays[1];
	$days = $noofdays[2];
	
	if($months == 11 && $days == 0){
		sendmail($mailid, $remainindays = "in a month");
		//echo "<br>One month remaining for the Renew";
	}
	if($months == 11 && $days == 28){
		sendmail($mailid, $remainindays = "in two days");
		//echo "<br>Two Days remaining for the Renew";
	}
	//printf("<br />%d years, %d months, %d days\n", $years, $months, $days);
}
?>

I have checked this link but i was unable to know tat where to use this code in plugin

http://www.s2member.com/forums/topic/automatic-renewal-reminder/

Thanks in advance

  • This reply was modified 4 years, 2 months ago by  chidu.
Posted: Tuesday Nov 6th, 2012 at 2:55 am #30750
chidu
Username: chidu

Hi, i have written for the cron job but i am not sure this ll work for me

  • This reply was modified 4 years, 2 months ago by  chidu.
Posted: Thursday Oct 25th, 2012 at 3:16 am #29612
chidu
Username: chidu

thanks it helped me

  • This reply was modified 4 years, 2 months ago by  chidu.
  • This reply was modified 4 years, 2 months ago by  chidu.
Viewing 3 replies - 1 through 3 (of 3 total)

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.