Your cart is empty!
Mailing Subscription
public function onDisplayMailingSubscriptionInput(object $user) : string
Fires while binding the values of the custom fields.
Description
Trigger hook to retrieve an optional field that could be used to confirm the subscription to a mailing list.
This event SHOULD NOT be used to dynamically add generic custom fields, which MUST be created from the configuration panel of VikAppointments or through the onBeforeRegisterCustomFields
hook.
Parameters
- $user
-
(object) An object holding the user details.
Return Value
String. The HTML to display as last field.
Example
The example below displays a checkbox that can be used to start/keep a mailing subscription.
NOTE: the management of the subscription should be made by using a different plugin.
/**
* Trigger event to retrieve an optional field that could be used
* to confirm the subscription to a mailing list.
*
* @param object $user The user details.
*
* @return string The HTML to display.
*/
public function onDisplayMailingSubscriptionInput($user)
{
$subsribed = false;
/**
* @todo check if the customer is already subscribed to a mailing list
*/
if ($subscribed)
{
// auto-check subscription field
$checked = 'checked="checked"';
$label = 'I want to continue to be subscribed to the newsletter';
}
else
{
// leave subscription field unchecked
$checked = '';
$label = 'I would like to subscribe to the newsletter (optional)';
}
// build field
$field = '<input type="checkbox" name="subscr_accept" value="1" id="subscr_accept" ' . $checked . ' />'
. "\n"
. '<label for="subscr_accept">' . $label . '</label>';
return $field;
}
Changelog
Version | Description |
---|---|
1.7 | Changed $user argument from array to object. |
1.6.3 | Introduced. |
Last Update: 2021-10-08 13:00
Helpful?