Am wondering the same thing in both cases. I sent Rod an email but didn't get a response and am unsure whether this feature made it into 1.1.12 I would really love to be able to give my users a head's up when their membership is about to expire.
Please Log in to join the conversation.
Please Log in to join the conversation.
However, you can use the CB User Manager to filter against CBSubs plan members and then further filter against expiration date criteria. Then you can Mass Email the resulting set.
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
<?php
//change these to your values
$username="sqlusername";
$password="sqlpassword";
$database="sql_dbname";
$hostname="localhost";
//leave this alone
$today=date('Y-m-d');
// Opens a connection to a mySQL server - leave alone
$connection=mysql_connect ($hostname, $username, $password);
if (!$connection) {
die('Not connected : ' . mysql_error());
}
// Set the active mySQL database - leave alone
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
die ('Cant use db : ' . mysql_error());
}
//change these to reflect your times - 1 day = 24hrs so 4 weeks = 672 hrs, etc, leave the 3600 alone
//you only need one of these per query but I put them all in each of my files
$week4 = strtotime($today) + 672*3600;
$week3 = strtotime($today) + 504*3600;
$week2 = strtotime($today) + 336*3600;
$week1 = strtotime($today) + 168*3600;
$zero = strtotime($today) + 24*3600; // (hint) 'today' works better if you had 24 hours
//leave these alone unless you change the $XXX values above. Do not start a variable with a number like this $4week - that's a no no
$expire= date('Y-m-d', $week4);
$expire2= date('Y-m-d', $week3);
$expire3= date('Y-m-d', $week2);
$expire4= date('Y-m-d', $week1);
$expire5= date('Y-m-d', $zero);
// 1 week GENERIC (name of this query - this query grabs all of my 'generic' members 1 week from their expiration
//change the plan_id to whatever value you need
//leave out the plan_id line all together if you want to query all Plans
//this particular query grabs all members except ones with plan_id = 1
//these $expire variables in the query need to match the one above that you want for this query be it one week or whatever
$q="SELECT jos_cbsubs_subscriptions.status, jos_cbsubs_subscriptions.user_id,
jos_cbsubs_subscriptions.plan_id, jos_cbsubs_subscriptions.expiry_date, jos_comprofiler.firstname,
jos_comprofiler.lastname, jos_users.email
FROM jos_cbsubs_subscriptions, jos_users, jos_comprofiler
WHERE jos_cbsubs_subscriptions.user_id = jos_users.id
AND jos_cbsubs_subscriptions.status = 'A'
AND jos_users.block = 0
AND jos_cbsubs_subscriptions.plan_id != 1
AND jos_cbsubs_subscriptions.expiry_date > '$expire4 00:00:00'
AND jos_cbsubs_subscriptions.expiry_date < '$expire4 23:59:59'
AND jos_cbsubs_subscriptions.user_id = jos_users.id
AND jos_comprofiler.user_id = jos_users.id";
$r=mysql_query($q);
//this will show you a message when you run the file manually so you can see if it works, change the message to your liking
if (!$r) {
die('Invalid query: ' . mysql_error());
}
else {
echo "<font color='green'>Success 1week generic!</font><br />";
}
while ($rr=mysql_fetch_array($r)) {
$day=$rr[expiry_date];
$ex_date=date('l, F j, Y',strtotime($day));
//this is the message you send - be sure to include a link back to your site to make it easy
//You can use HTML and single quotes, but no double quotes in between the double quotes!
//so be careful when adding links to only use single quotes
$message="Dear $rr[firstname], <br /><br />
<b>Your membership expires in 1 week!<b><br /><br />Please <a href='http://www.mysites.com'>click here</a> to renew.<br /><br />Thank You";
//change subject line to your liking
$subject="Your membership expires in 1 Week";
$recipient = $rr[email];
//leave all of this alone unless you know what you're doing
$body = "<html>\n";
$body .= "<body style=\"font-family:Verdana, Verdana, Geneva, sans-serif; font-size:12px; color:#000;\">\n";
$body = $message;
$body .= "</body>\n";
$body .= "</html>\n";
//change all of these to whatever emails you need, change NAME to what you want people to see in their inbox
$headers = "From: NAME <webadmin@yoursite.com>\r\n";
$headers .= "Reply-To: name@email.com\r\n";
$headers .= "Return-Path: name@email.com\r\n";
$headers .= 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
return mail($recipient, $subject, $message, $headers);
}
?>
Please Log in to join the conversation.