Si Posted August 18, 2011 Share Posted August 18, 2011 @jeremyhaber and @mgaccess thank you Have uploaded and modified the code as needed. Haven't yet tested as I'm on vacation but will do so within the next week or so. If you find anything else, please update this thread......I really appreciate the input and help. Si 0 Quote Link to comment Share on other sites More sharing options...
mgaccess Posted August 18, 2011 Share Posted August 18, 2011 @jeremyhaber I updated the code as you suggested (attached), but the cron job doesn't send any emails at all. I've edited the product registration dates several times just to be sure. Any suggestions? (note the "warndaysX" 2, 4, 6 is just for testing) end_free_trials_hook.txt 0 Quote Link to comment Share on other sites More sharing options...
jeremyhaber Posted August 19, 2011 Share Posted August 19, 2011 @jeremyhaber, I assume this was a typo ($withinTime[3] <= 86400 && $withinTime[2] )? }elseif ($withinTime[2] <= 86400 && $withinTime[2] > 0) { sendMessage("$warn3",$id); }elseif ($withinTime[3] <= 86400 && $withinTime[2] > 0) { sendMessage("$warn2",$id); }elseif ($withinTime[4] <= 86400 && $withinTime[3] > 0) { sendMessage("$warn1",$id); } and should be changed to this: You are correct a slight typo. Sorry about that. @jeremyhaber and @mgaccess thank you Have uploaded and modified the code as needed. Haven't yet tested as I'm on vacation but will do so within the next week or so. If you find anything else, please update this thread......I really appreciate the input and help. Si No problem! You are absolutely welcome. @jeremyhaber I updated the code as you suggested (attached), but the cron job doesn't send any emails at all. I've edited the product registration dates several times just to be sure. Any suggestions? (note the "warndaysX" 2, 4, 6 is just for testing) Modified it slightly on my end removing the database queries and some includes. Since I am running a test file right now on a live server. This is essentially the same logic I included in the file. http://whmcsaddon.com/myaccount/trial-test.php?date=2011-08-18 You may need to change the date variable. This link above is for first warning as of today the 19th. Everything seems to be working correctly. Maybe set a quick PHP mail function to email you and let you know it's at least running. It could very well be that nothing was in the proper date parameters to run and send mail. 0 Quote Link to comment Share on other sites More sharing options...
mgaccess Posted August 19, 2011 Share Posted August 19, 2011 Modified it slightly on my end removing the database queries and some includes. Since I am running a test file right now on a live server. This is essentially the same logic I included in the file. http://whmcsaddon.com/myaccount/tria...ate=2011-08-18 You may need to change the date variable. This link above is for first warning as of today the 19th. Sorry I don't quite understand what you are trying to say. Did you modify the file attached to my previous message? The link only shows text. (I'm certainly not a programmer by the way - just enough to be dangerous). What are you suggesting? Thanks 0 Quote Link to comment Share on other sites More sharing options...
jeremyhaber Posted August 19, 2011 Share Posted August 19, 2011 Sorry I don't quite understand what you are trying to say. Did you modify the file attached to my previous message? The link only shows text. (I'm certainly not a programmer by the way - just enough to be dangerous). What are you suggesting? Thanks Simply the link above just tests out the logic of when to run. It is essentially the same code that you have just removed the sendmessage/suspend/terminate functions and replaced them with text. So that when the date is set for them to execute it will display "Warn 1"/"Warn 2"/"Warn 3".... Changing the date in the URL above will change the sample registration date. Just showing you that the code you have should work. 0 Quote Link to comment Share on other sites More sharing options...
mgaccess Posted August 19, 2011 Share Posted August 19, 2011 Okay thanks. Well, not sure why it's not working on my test server when I run the job manually or via the cron job. The original code works fine, but just continuously sends emails everyday which renders it useless. Ugh, back to the drawing board. Thanks for your help so far. 0 Quote Link to comment Share on other sites More sharing options...
jeremyhaber Posted August 20, 2011 Share Posted August 20, 2011 This maybe the reason why: $regdate = time()-strtotime("2011-07-28"); Must have changed that for testing reasons. Just a little bugger... always is. Should be: $regdate = time()-strtotime($rows["regdate"]); Hope that resolves the problem 0 Quote Link to comment Share on other sites More sharing options...
mgaccess Posted September 6, 2011 Share Posted September 6, 2011 I finally got this working correctly on my test servers - I like it. What if I did NOT want to actually delete the account from the server after 45 days (or whatever)? It is fine to still send the "terminate" email and go through the motions, but I want to manually delete trial accounts from the server. Anyone know what part to edit? Should I just comment out the &sql and $rs statements below? if ($regdate == $terminatedays) { sendMessage("$terminate",$id); $sql = "insert into tblcancelrequests (date,relid,reason,type) VALUES (now(),".$id.",'Trial Account','Immediate')"; $rs = mysql_query($sql); }elseif ($regdate == $suspenddays) { sendMessage("$suspend",$id); ServerSuspendAccount($id); Also, does this mod only affect accounts that are "Active" or "Suspended"? Thanks 0 Quote Link to comment Share on other sites More sharing options...
jasonthewebmaster Posted September 7, 2011 Share Posted September 7, 2011 wow, cool mod! funny how some people just don't get stuff no matter how much you explain it heheh 0 Quote Link to comment Share on other sites More sharing options...
thunderesl Posted September 9, 2011 Share Posted September 9, 2011 Hi Guys, This looks like a great mod. I just wanted to check something about installation. I keep seeing people mentioning a cron job does this mod require that i setup a specific cron job? From what I can tell I just edit the file as I want and upload it but just wanted to be sure. Any help will be much appreciated. Best regards, Vasilis 0 Quote Link to comment Share on other sites More sharing options...
jeremyhaber Posted September 9, 2011 Share Posted September 9, 2011 I noticed emails weren't sending out recently. And added: $warn1 = $data["warn1"]; $warn2 = $data["warn2"]; $warn3 = $data["warn3"]; $suspend = $data["suspend"]; $terminate = $data["terminate"]; Just before this line: $query = "SELECT tblhosting.id,tblhosting.regdate,tblproducts.servertype FROM tblhosting INNER JOIN tblproducts ON tblproducts.id=tblhosting.packageid WHERE packageid=".(int)$pid." AND regdate<'$warndays1' AND (domainstatus='Active' OR domainstatus='Suspended')"; It resolved my issue. Double check that your emails are in fact sending out. And to make it a bit more versatile you can do a check to see if the email is set before sending out an email. For example: if ($terminate) sendMessage($terminate,$id); 0 Quote Link to comment Share on other sites More sharing options...
hawk Posted January 4, 2012 Share Posted January 4, 2012 I tried the script, perhaps its installed wrong so it doesn't work. But the thoughts of trial abuse come to mind. Even if I can get this to work, how does one prevent users from just getting many free trials over time or by some other way like different domain names or IP addresses they are coming from? Cheers 0 Quote Link to comment Share on other sites More sharing options...
Powercom Posted April 7, 2012 Share Posted April 7, 2012 Hi we are also finding that the warning emails are being sent every day.ie. the client gets 4 First Notice Trial Ending emails,then on the 5th day they get the second warning - this is then sent every day until the third warning etc.... I have been through the posts on this topic and cannot find a solution to this problem. Has anyone got a difinitive answer to what may work.? Apart from this, it seems to be an awesome mod. Thanks in advance. Regards to all. Hi,We are finding that the warning emails are being sent every day.ie. the client gets 4 First Notice Trial Ending emails,then on the 5th day they get a a second warning - this is then sent every day until the third warning etc. so should if ($regdate < $terminatedays) { sendMessage("$terminate",$id); $sql = "insert into tblcancelrequests (date,relid,reason,type) VALUES (now(),".$id.",'Trial Account','Immediate')"; $rs = mysql_query($sql); }elseif ($regdate < $suspenddays) { sendMessage("$suspend",$id); ServerSuspendAccount($id); }elseif ($regdate < $warndays3) { sendMessage("$warn3",$id); }elseif ($regdate < $warndays2) { sendMessage("$warn2",$id); }elseif ($regdate < $warndays1) { sendMessage("$warn1",$id); } be changed to if ($regdate = $terminatedays) { sendMessage("$terminate",$id); $sql = "insert into tblcancelrequests (date,relid,reason,type) VALUES (now(),".$id.",'Trial Account','Immediate')"; $rs = mysql_query($sql); }elseif ($regdate = $suspenddays) { sendMessage("$suspend",$id); ServerSuspendAccount($id); }elseif ($regdate = $warndays3) { sendMessage("$warn3",$id); }elseif ($regdate = $warndays2) { sendMessage("$warn2",$id); }elseif ($regdate = $warndays1) { sendMessage("$warn1",$id); } 0 Quote Link to comment Share on other sites More sharing options...
devilx1985 Posted May 14, 2012 Share Posted May 14, 2012 Hi man! i need your support please, can you contact me or give me your email? 0 Quote Link to comment Share on other sites More sharing options...
mcpacific Posted February 20, 2013 Share Posted February 20, 2013 (edited) [i re-posted this one with a quote and a more-specific question, so removing the text from this post] Edited February 20, 2013 by la_rollin 0 Quote Link to comment Share on other sites More sharing options...
mcpacific Posted February 20, 2013 Share Posted February 20, 2013 (edited) I was also wondering, does anyone have any suggestions on how to easily test this hook, without having to run the actual days to invoke each option? Edited February 20, 2013 by la_rollin 0 Quote Link to comment Share on other sites More sharing options...
mcpacific Posted February 20, 2013 Share Posted February 20, 2013 (edited) What if you just want to remove the 2nd and 3rd warning for one product, but you need to have them for others? Can you just remove the corresponding items in the free trials array without breaking the hook? Yes just delete the lines: elseif ($regdate = $warndays2) { sendMessage("$warn2",$id); }elseif ($regdate = $warndays1) { sendMessage("$warn1",$id); } then set the warn days 3 line in the configuration portion. Edited February 20, 2013 by la_rollin 0 Quote Link to comment Share on other sites More sharing options...
webio Posted April 16, 2013 Share Posted April 16, 2013 Hello, does someone is using this addon on latest WHMCS 5.2.x version? There has been changed in latest version what products can be cancelled using cron job and even if cancellation request is being made for free product and this cancellation is being added to cancellation requests list this request is not being processed by cron job and is still visible in cancellation requests list (it doesn't matter if it is Immediate or End of billing period type). If I reported this as a support request I've got response that I should send a feature quests for that so I did: http://requests.whmcs.com/responses/cancellation-requests-from-version-52x-excludes-free-products-quiet-breaking-change-no-info-in-changelog-for-some-of-use-please-re-add-this-possibility Please vote for it because I have totally no idea why this has been changed. Free product is product even if it is free and client should have possibility to cancel it. Regards 0 Quote Link to comment Share on other sites More sharing options...
webio Posted April 17, 2013 Share Posted April 17, 2013 Hello, I have confirmation that this will be readded to 5.2.4 version so feature request will be marked as resolved soon. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.