Skip to content

Instantly share code, notes, and snippets.

View mhrubel's full-sized avatar
💼
Open to Work

Mahamudul Hasan Rubel mhrubel

💼
Open to Work
View GitHub Profile
@mhrubel
mhrubel / 2011-08-18_whmscripts_disabling_invoice_emails.md
Created February 8, 2019 15:05 — forked from RWJMurphy/2011-08-18_whmscripts_disabling_invoice_emails.md
WHMScripts: Disabling invoice creation emails in WHMCS on a per-client basis

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/)

@mhrubel
mhrubel / disable_zero_invoices.php
Created February 8, 2019 15:01 — forked from Pierowheelz/disable_zero_invoices.php
A hook for WHMCS which disables email notifications for invoices with a zero total. Modified from existing code to use the new Capsule database handler ( http://www.whmcsjet.com/how-to-disable-invoice-generation-for-0-00-invoices/ ).
<?php
if (!defined("WHMCS"))
die("This file cannot be accessed directly");
use WHMCS\Database\Capsule;
function disable_00_invoices($vars) {
$merge_fields = array();
$email_template_name = $vars['messagename']; # Email template name being sent
@mhrubel
mhrubel / mark_zero_invoices_paid.php
Created February 8, 2019 15:00 — forked from Pierowheelz/mark_zero_invoices_paid.php
A hook for WHMCS which marks invoices which have received payment as paid, where the WHMCS system doesn't automatically mark them paid. I found that if manually associating a transaction with an invoice number in WHMCS, the invoice is not marked as paid even when there is zero total remaining. This fixes that.
<?php
if (!defined("WHMCS"))
die("This file cannot be accessed directly");
use WHMCS\Database\Capsule;
function wb_mark_zero_invoices_paid(){
//get all unpaid invoices
$unpaid_invoices = Capsule::table('tblinvoices')->where('status', 'Unpaid')->get();
foreach( $unpaid_invoices as $inv ){
@mhrubel
mhrubel / set_sub_account_info.php
Created February 8, 2019 15:00 — forked from Pierowheelz/set_sub_account_info.php
A WHMCS hook to copy Company Name and Address from Clients to Contacts (sub-accounts) upon creation of a new Contact. This ensures that invoices always show the correct Company Name and Address.
<?php
if (!defined("WHMCS"))
die("This file cannot be accessed directly");
use WHMCS\Database\Capsule;
/*
* Copies account details from parent accounts to sub-accounts
*/
add_hook('ContactAdd', 1, "wb_setup_sub_accounts");
@mhrubel
mhrubel / jucra-affiliates-to-clients-matching.php
Created February 8, 2019 14:56 — forked from craigedmonds/jucra-affiliates-to-clients-matching.php
WHMCS custom matching of affiliates to clients (custom hook)
<?php
/*
Custom WHMCS Affiliate hook by [email protected]
Date: 14th October 2018
Stored in WHCMS: /includes/hooks/
The WHMCS affiliate system is basic, very basic in terms of: affiliates can only
earn comissions based on orders they generate.
#!/bin/bash -i
#
password="priv8area"
function cgi_get_POST_vars()
{
# check content type
[ "${CONTENT_TYPE}" != "application/x-www-form-urlencoded" ] && \
<?php
if ( is_user_logged_in() ) {
} else { ?>
<a href="http://writers-site.com/whmcs-2/?ccce=register">Sign Up</a>
<?php
};
?>
@mhrubel
mhrubel / invoicepdf.tpl
Created February 8, 2019 14:52 — forked from maevelander/invoicepdf.tpl
Custom Invoice PDF template for WHMCS
<?php
# Logo
$logoFilename = 'placeholder.png';
if (file_exists(ROOTDIR . '/assets/img/logo.png')) {
$logoFilename = 'logo.png';
} elseif (file_exists(ROOTDIR . '/assets/img/logo.jpg')) {
$logoFilename = 'logo.jpg';
}
$pdf->Image(ROOTDIR . '/assets/img/' . $logoFilename, 15, 25, 75);
<?php
/**
* Generate uuids for clients and admins that don't have uuids set.
*
* The WHMCS 6.2.0 update process automatically inserts uuids, but if your
* installation bypasses WHMCS update routines then this will generate uuids for
* the client and admin users that don't have one yet.
*
* Warning! Please back up at least your tblclient and tbladmin tables before
<?php
/**
* Custom Affliates Redirects
* © 2017 gofas.net
*
*/
add_hook('AffiliateClickthru', 1, function($vars) {
$affiliate_id = (int)$vars['affiliateId'];
$destination = (string)'https://example.com'; // default destination after affiliate link click