Jump to content

Disable Payment Reminder for select customers


Recommended Posts

  • 2 weeks later...
  • WHMCS Support Manager

Hi @John Kennedy,

At present overdue reminders can be disabled on a per-account basis, but not other invoice emails. There are some existing feature requests with a handful of votes thus far, so please do add yours:

Link to comment
Share on other sites

  • 2 weeks later...
On 12/18/2017 at 16:48, John Kennedy said:

What I'm looking to do is to stop "Invoice Unpaid Reminders" from going out to certain customers.
I'm guessing this is achievable with a hook, but I can't find anything with "Client ID" on it.

you could try modifying the hook in the thread below....

it should just be a case of modifying the values of $client_ids and $message_names - ultimately, i'll have to be rewrite it and replace the SQL code (e.g convert it to SQL) - simple enough task, but the above hook should work until at least v8 (which is probably 6 months away at least).

Link to comment
Share on other sites

  • 2 months later...

Thanks brian!, that's just what I was looking for. Seems to be working for the test client.
I'm assuming I can stop any type if email from being sent by modifying the $client_ids and $message_names arrays.
That kind of creates a second question:
If I want to stop 3 templates from going to 2 customers, but only 2 templates to the 3rd customer. Would I have to set up a different hook for the 3rd customer or would that conflict with the original hook?

Link to comment
Share on other sites

Hi John,

17 hours ago, John Kennedy said:

I'm assuming I can stop any type if email from being sent by modifying the $client_ids and $message_names arrays.

yes.

17 hours ago, John Kennedy said:

If I want to stop 3 templates from going to 2 customers, but only 2 templates to the 3rd customer. Would I have to set up a different hook for the 3rd customer or would that conflict with the original hook?

oooh my head! :67_head_bandage:

short answer is there won't be any conflict if you use two hooks correctly.

better answer would be to write the hook in such a way that you control which users don't get which templates... so if you tweak the updated code posted by @sentq from the thread below...

<?php

use WHMCS\Database\Capsule;

add_hook("EmailPreSend", 1, function($vars){
	
    if ($vars['messagename'] === "Invoice Payment Reminder"){
    	$getClientId = Capsule::table("tblinvoices")->where("id", $vars['relid'])->first();
      	if (in_array($getClientId->userid, array(1, 12, 25))){
        	return array("abortsend" => true);
        }
    }
    elseif ($vars['messagename'] === "Invoice Created"){
    	$getClientId = Capsule::table("tblinvoices")->where("id", $vars['relid'])->first();
      	if (in_array($getClientId->userid, array(1, 12))){
        	return array("abortsend" => true);
        }
    }
});

so you can go through each template and define who won't receive those particular emails... you can tidy this up a lot and group templates together, but my head still hasn't recovered from your 3 templates to 2, and 2 templates to three... :twisted:

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated