Skip to main content
Version: v9 (Current)

Add Custom Fields to WordPress Notification Carrier Forms

WordPress notification carrier forms can be extended with custom fields to capture additional user input and configuration options. This guide shows you how to add custom form fields to existing carriers like Email using WordPress hooks and the notification API.

use BracketSpace\Notification\Repository\Carrier\Email;
use BracketSpace\Notification\Repository\Field\InputField;

add_action(
'notification/carrier/registered',
function($carrier)
{
if (! $carrier instanceof Email::class) {
return;
}

$carrier->addFormField(
new InputField(
[
'label' => __('Example Field', 'textdomain'),
'name' => 'example',
'resolvable' => true,
]
)
);
}
);
note

All the field data will be automatically stored and available in $carrier->data property in send() method.