benecaster_forward_email_to_admin()
benecaster_forward_email_to_admin( int $log_id, int $admin_id ): int|WP_Error
Sends an administrator a review copy of one logged email, so they can see how it looks: the stored body, sender and headers, with [Review copy] in front of the subject, to the administrator’s own address.
The copy is queued and logged as a test send, so it goes out even on a copy of the site, where the original is held. The original is left as it was: a held email stays held, and the listener receives nothing. Any logged email with a stored copy can be forwarded, whatever its status, and there is no opt-out check, since the listener is not the recipient. benecaster_test_email_queued and then benecaster_email_forwarded fire.
Parameters
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
log_id |
int |
— | Yes | The id of a row from benecaster_get_email_log(). |
admin_id |
int |
— | Yes | The WordPress user to send the copy to. It must be able to manage_options. There is no way to name an address, so the copy cannot be sent outside the site's administrators. |
Return Value
Type:
int|WP_Error
The new email queue row id, or a WP_Error saying why nothing was sent. The error's data carries an HTTP status.
Example
if ( current_user_can( 'manage_options' ) ) {
// Always to the person asking.
$result = benecaster_forward_email_to_admin( $log_id, get_current_user_id() );
}
Hooks Fired
Notes
The links in the copy work, and they are the listener's. Its feed URL carries their private token, a sign-in link signs whoever clicks it in as that listener, and an unsubscribe link unsubscribes them. Say so wherever you offer this. Only the List-Unsubscribe and List-Unsubscribe-Post headers are removed, so a mail client's own Unsubscribe button cannot act on the listener.
Refused with a WP_Error, and nothing sent:
- benecaster_forward_not_found (404) — no log row with that id.
- benecaster_forward_not_admin (403) — no such user, no address on the account, or it cannot manage_options.
- benecaster_forward_past_retention (409) — older than benecaster_get_email_log_retention_days().
- benecaster_forward_no_stored_copy (409) — no stored copy of the email, as for a suppressed or test row.
- benecaster_forward_queue_failed (500) — the queue write failed; try again.
There is no capability check on the caller: check manage_options first. See Send yourself a review copy of a logged email.
Need this built rather than just documented? See our services →