Before Send Subject
apply_filters_ref_array( 'vikappointments_before_send_mail_subject_{$type}', bool $send, string &$subject, object $data )
Fires while fetching the subject to use for notification e-mails.
Description
Plugins can use this filter to manipulate at runtime the subject to use for e-mail notifications.
The dynamic portion of the hook name, $type, refers to the type of event that triggered the e-mail sending.
Here's a list of supported types:
- customer
- admin
- cancellation
- employee
- waitlist
- package
- packadmin
- usernote
This means that, for example, the notification e-mail sent to the customers will trigger a filter called vikappointments_before_send_mail_subject_customer.
Parameters
- $send
- 
(bool) Use false to prevent the e-mail sending. 
- &$subject
- 
(string) The current subject of the e-mail. Since the argument is passed as reference, it is possible to manipulate it. 
- $data
- 
(mixed) The entity to notify. In case of an appointment, the argument will be a VAPOrderAppointmentobject.
The hook might specify additional arguments, which can vary according to the current type.
Example
The example below uses a different e-mail subject depending on the status of the order. The new subject is applied only to the notification e-mail sent to the customers for appointments.
/**
 * Triggers a filter to let the plugins be able to handle the subject of the e-mail.
 *
 * The hook name is built as:
 * vikappointments_before_send_mail_subject_[type]
 *
 * @param  boolean  $send      False to prevent the e-mail sending.
 * @param  string   &$subject  The current e-mail subject.
 * @param  object   $order     The appointment details.
 */
add_filter('vikappointments_before_send_mail_subject_customer', function($send, &$subject, $order)
{
    if ($order->status == 'C')
    {
        $subject = __('Your order has been confirmed', 'myplugin');
    }
    else if ($order->status == 'P')
    {
        $subject = __('Your order has been paid', 'myplugin');
    }
    else if ($order->status == 'W')
    {
        if ($order->id_payment > 0)
        {
            $subject = __('Your order requires a payment', 'myplugin');
        }
        else
        {
            $subject = __('Your order is waiting for a manual approval', 'myplugin');
        }
    }
    return $send;
}, 10, 3);Changelog
| Version | Description | 
|---|---|
| 1.2 | Introduced. |