English (United Kingdom)
Knowledge Base  >  Vik Appointments  >  Hooks  >  Quick Contact  >  Before Send Employee

apply_filters( 'vikappointments_before_quick_contact_send', bool $send, int $id_employee, string &$subject, string &$content, bool &$is_html, array &$sender, array &$recipients, JModelVAP $model )

Fires while before sending an e-mail to the employee through the Quick Contact feature.


Description

Trigger event to allow the plugins to manipulate quick contact messages for the given employee.

It is possible to throw an exception to avoid sending the e-mail. The exception text will be used as error message.

This hook can be used, in example, to ban certain e-mail/IP addresses or to forward the same message to several recipients.


Parameters

$send

(bool)  True to send the message, false to deny it.

$id_employee

(int)  The ID of the employee to notify.

&$subject

(string)  The subject of the e-mail, by default equals to "New Quick Contact".

&$content

(string)  The content of the e-mail, which is equals to the message wrote by the customer.

&$is_html

(bool)  True in case the content of the e-mail includes HTML tags (always false by default). Useful in case a plugin needs to include HTML tags to the body.

&$sender

(array)  An associative array containing the name and the email of the customer. In case the mail is configured to send messages only by a specific domain, than it is appropriate to alter the email attribute and to include the mail address of the customer within the body.

&$recipients

(array)  An array containing all the mail addresses to notify. By default, the array contains only the e-mail of the employee.

$model

(JModelVAP)  The model responsible of sending the e-mail.


Example

/**
 * Trigger event to allow the plugins to manipulate quick contact messages for the given
 * employee. It is possible to throw an exception to avoid sending the message.
 * The exception text will be used as error message.
 *
 * @param  boolean  $send         False to prevent e-mail sending (added @since 1.2).
 * @param  integer  $id_employee  The employee ID.
 * @param  string   &$subject     The e-mail subject.
 * @param  string   &$content     The e-mail content (the customer message). 
 * @param  boolean  &$is_html     True if the e-mail should support HTML tags.
 * @param  string   &$sender      The e-mail sender details (added @since 1.2). 
 * @param  array    &$recipients  A list of recipient e-mails (added @since 1.2).
 * @param  JModel   $model        The current model (added @since 1.2).
 */
add_filter('vikappointments_before_quick_contact_send', function($send, $id_employee, &$subject, &$content, &$is_html, &$sender, &$recipients, $model)
{
    // include customer details at the beginning of the body
    $content = sprintf("E-mail sent by %s (%s)\n\n", $sender['name'], $sender['email']) . $content;

    // overwrite sender details
    $sender['email'] = 'info@mydomain.com';

    // always forward the e-mail to the address of the moderator
    $recipients[] = 'moderator@mydomain.com';

    return $send;
}, 10, 8);

Changelog

Version Description
1.2 Switched from do_action_ref_array to apply_filters_ref_array to accept a return value, which will be used to allow/deny the e-mail sending.
Added $sender, $recipients and $model arguments.
1.0 Introduced.
Last Update: 2021-08-05
Helpful?
This site uses cookies. By continuing to browse you accept their use. Further information