Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save paradigmaweb/611548e047f83cde68eecadd2383c294 to your computer and use it in GitHub Desktop.

Select an option

Save paradigmaweb/611548e047f83cde68eecadd2383c294 to your computer and use it in GitHub Desktop.

Revisions

  1. Reed Kraft-Murphy renamed this gist Feb 17, 2018. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. Reed Kraft-Murphy revised this gist Feb 17, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion _.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@ If you’re using WHMCS to manage your cPanel shared servers, this is probably a

    Normally WHMCS only allows you to disable these emails globally but, by making use of the EmailPreSend action hook, we can set up a list of clients not to receive these.

    To get started just download the following script, change the file extension to .php, edit it to set up the $client_ids and place it in your WHMCS /includes/hooks/ directory
    To get started just download the following script, change the file extension to `.php`, edit it to set up the `$client_ids` and place it in your WHMCS `/includes/hooks/` directory

    Please note, this script doesn’t disable only the automatically sent invoice notification emails, but also blocks manual sending of these for the selected clients.

  3. Reed Kraft-Murphy revised this gist Feb 17, 2018. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions _.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    If you’re using WHMCS to manage your cPanel shared servers, this is probably a request that you’ve received a few times. You have clients that are set up to pay invoices automatically from their credit cards, and they’d rather not receive the “Invoice Created” or “Invoice Payment Reminder” emails every month.

    Normally WHMCS only allows you to disable these emails globally but, by making use of the EmailPreSend action hook, we can set up a list of clients not to receive these.

    To get started just download the following script, change the file extension to .php, edit it to set up the $client_ids and place it in your WHMCS /includes/hooks/ directory

    Please note, this script doesn’t disable only the automatically sent invoice notification emails, but also blocks manual sending of these for the selected clients.

    (originally posted at http://whmscripts.net/whmcs/2011/disabling-invoice-creation-emails-in-whmcs-on-a-per-client-basis/)
  4. Reed Kraft-Murphy created this gist Feb 17, 2018.
    77 changes: 77 additions & 0 deletions disable_invoice_notification.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,77 @@
    <?php
    /*
    * disable_invoice_notification.php
    * Version 1.0
    *
    * An action hook for WHMCS that allows you to disable sending of invoice
    * creation notifications for selected clients.
    *
    * To install, just set the $client_ids and (optionally) $logfile variables
    * then place this script in your whmcs/includes/hooks/ directory.
    *
    * Tested with WHMCS 4.5.2
    *
    * Reed Murphy <[email protected]> 2010
    *
    * For more free cPanel / WHM / WHMCS scripts, check out http://whmscripts.net/
    */

    function hook_disable_invoice_notification($vars) {
    // If $logfile is not blank, messages about emails not sent will be
    // logged to this file.
    // $logfile = "/home/whmcs/presendemail.log";
    // $logfile = "";
    $logfile = "";

    // An array of IDs of clients that should not receive invoice notification
    // emails. Replace these with your own.
    $client_ids = Array(
    "1234",
    "999"
    );

    // The names of the email templates that you don't want sent.
    $message_names = Array(
    "Credit Card Invoice Created",
    "Invoice Created",
    "Invoice Payment Reminder"
    );

    $merge_fields = array();
    if (in_array($vars['messagename'], $message_names)) {
    $invoice_id = mysql_real_escape_string($vars['relid']);
    $query =
    "SELECT `userid`, CONCAT_WS(' ', `firstname`, `lastname`) as 'name' ".
    "FROM `tblinvoices` ".
    "JOIN `tblclients` ON `tblinvoices`.`userid` = `tblclients`.`id` ".
    "WHERE `tblinvoices`.`id` = '" . $invoice_id ."'";
    $r = full_query($query);
    if ($r) {
    $row = mysql_fetch_row($r);
    $client_id = $row[0];
    $client_name = $row[1];
    if (in_array($client_id, $client_ids)) {
    $merge_fields['abortsend'] = true; // don't send email

    if ($logfile) {
    $pid = getmypid();
    $logline = sprintf(
    "%s pre_send_email[%d]: ".
    "Not sending email '%s' to client %s\n",
    date("Y-m-d H:i:s"),
    $pid,
    $vars['messagename'],
    $client_name
    );
    $fh = fopen($logfile, "a");
    fwrite($fh, $logline);
    fclose($fh);
    }
    }
    }
    }

    return $merge_fields;
    }

    add_hook("EmailPreSend", 10, "hook_disable_invoice_notification");