在发送通知之前执行以允许应用附加条件标准和处理通知消息。
参数
变量 | 类型 | 注意 |
---|---|---|
eventType | string | 事件类型例如:票证、发票、订单、服务或域 |
eventName | string | 事件名称。 |
rule | \WHMCS\Notification\Rule | 已匹配的通知规则模型。 |
hookParameters | array | 钩子参数数组。会因触发器而异。 |
notification | \WHMCS\Notification\Notification | 通知对象。请参阅https://docs.whmcs.com/classes 的课程文档 |
响应
不支持响应
示例代码
<?php
add_hook('NotificationPreSend', 1, function($vars) {
$eventType = $vars['eventType'];
$eventName = $vars['eventName'];
$rule = $vars['rule'];
$hookParameters = $vars['hookParameters'];
$notification = $vars['notification'];
// Perform additional conditional logic and throw the AbortNotification
// exception to prevent the notification from sending.
if ($eventType == 'Invoice'
&& $eventName == 'created'
&& (isset($hookParameters['invoiceid'])
&& $hookParameters['invoiceid'] > 1000)
) {
throw new \WHMCS\Notification\Exception\AbortNotification();
}
// If allowing the notification to continue, you can manipulate the
// notification using the \WHMCS\Notification\Notification object.
$notification->setTitle('Override notification title');
$notification->setMessage('Override notification message body');
});
相关用法
- PHP WHMCS NetworkIssueClose用法及代码示例
- PHP WHMCS NetworkIssueReopen用法及代码示例
- PHP WHMCS NetworkIssueDelete用法及代码示例
- PHP WHMCS NetworkIssueEdit用法及代码示例
- PHP WHMCS NetworkIssueAdd用法及代码示例
- PHP WHMCS ClientAreaPageDownloads用法及代码示例
- PHP Ds\Map isEmpty()用法及代码示例
- PHP PHPUnit assertIsNotFloat()用法及代码示例
- PHP disk_total_space()用法及代码示例
- PHP ReflectionClass getTraitAliases()用法及代码示例
- PHP hash_hmac()用法及代码示例
- PHP String wordwrap()用法及代码示例
- PHP XMLWriter endPi()用法及代码示例
- PHP SimpleXMLElement children()用法及代码示例
- PHP IntlCalendar getTimeZone()用法及代码示例
- PHP SplPriorityQueue isCorrupted()用法及代码示例
- PHP XMLReader::getParserProperty()用法及代码示例
- PHP imagegif()用法及代码示例
- PHP imageresolution()用法及代码示例
- PHP array_reverse()用法及代码示例
- PHP IntlCalendar getActualMinimum()用法及代码示例
- PHP WHMCS DomainGetWhoisInfo用法及代码示例
- PHP metaphone()用法及代码示例
- PHP WHMCS ClientAreaHeaderOutput用法及代码示例
- PHP imagebmp()用法及代码示例
注:本文由纯净天空筛选整理自whmcs.com大神的英文原创作品 NotificationPreSend。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。