benecaster_test_email_queued
Fires when a test send reaches the email queue — an email editor’s “send me a test”, made with benecaster_send_test_email(). It fires in place of benecaster_after_email_send, and benecaster_before_email_send does not fire for a test either, so nothing that reacts to a real welcome or receipt (a counter, a CRM tag, a notification) reacts to a test.
A test renders exactly as a real send of that type does, with sample values for any merge tag that would otherwise be empty, but it skips the opt-out check, because it goes to whoever asked for it. Benecaster’s email log records it as test. As with the after-send action, queued is not delivered: the queue row is where to see whether it went out.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$email_type |
string |
— | Email type string of the email being tested |
$recipient |
string |
— | The address the test was sent to; it need not belong to an account |
$subject |
string |
— | Resolved subject line |
$user_id |
int|null |
— | WordPress user ID; null for a test made with `benecaster_send_test_email()` |
$show_id |
int|null |
— | Show whose branding the test uses, or null for an email sent outside any show |
$queue_id |
int |
— | The email queue row id |
Examples
Count the tests an editor sends
add_action( 'benecaster_test_email_queued', function (
string $email_type,
string $recipient,
string $subject,
?int $user_id,
?int $show_id,
int $queue_id
): void {
$key = 'my_addon_tests_' . $email_type;
update_option( $key, (int) get_option( $key, 0 ) + 1, false );
}, 10, 6 );
Need this built rather than just documented? See our services →