woocommerce_email_editor_send_preview_email_without_post_permission │ filter-hook │ WC 2.16.0

Filters whether a preview email may be sent for a request without a backing post.

Defaults to false: postless requests are rejected unless an integration that handles them (via the woocommerce_email_editor_send_preview_email explicitly authorizes the request.

Usage

add_filter( 'woocommerce_email_editor_send_preview_email_without_post_permission', 'wp_kama_woocommerce_email_editor_send_preview_without_post_permission_filter', 10, 2 );

/**
 * Function for `woocommerce_email_editor_send_preview_email_without_post_permission` filter-hook.
 * 
 * @param bool             $allowed Whether the postless request is authorized.
 * @param \WP_REST_Request $request The send-preview REST request.
 *
 * @return bool
 */
function wp_kama_woocommerce_email_editor_send_preview_without_post_permission_filter( $allowed, $request ){
	// filter...
	return $allowed;
}
$allowed(true|false)
Whether the postless request is authorized.
Default: false
$request(\WP_REST_Request)
The send-preview REST request.

Changelog

Since 2.16.0 Introduced.

Where the hook is called

Email_Editor::register_email_editor_api_routes()
woocommerce_email_editor_send_preview_email_without_post_permission
woocommerce/packages/email-editor/src/Engine/class-email-editor.php 294
return (bool) apply_filters( 'woocommerce_email_editor_send_preview_email_without_post_permission', false, $request );

Where the hook is used in WooCommerce

woocommerce/src/Internal/EmailEditor/Integration.php 177
add_filter( 'woocommerce_email_editor_send_preview_email_without_post_permission', array( $this, 'authorize_postless_send_preview' ), 10, 2 );