woocommerce_email_content_post_data
Filter the email content post data before creating the post.
Allows third-party integrators to modify the post data (title, content, meta, etc.) before the email content post is created.
Besides post creation, this also runs whenever the canonical file template content is computed — including the email send path (front-end, cron, CLI), where only post_content the filtered array is used. On the creation path post_status system-owned and not honored. Callbacks must not assume admin context.
Usage
add_filter( 'woocommerce_email_content_post_data', 'wp_kama_woocommerce_email_content_post_data_filter', 10, 3 );
/**
* Function for `woocommerce_email_content_post_data` filter-hook.
*
* @param array $post_data The post data array to be used for wp_insert_post().
* @param string $email_type The email type identifier (e.g., 'customer_processing_order').
* @param \WC_Email $email The WooCommerce email object.
*
* @return array
*/
function wp_kama_woocommerce_email_content_post_data_filter( $post_data, $email_type, $email ){
// filter...
return $post_data;
}
- $post_data(array)
- The post data array to be used for wp_insert_post().
- $email_type(string)
- The email type identifier (e.g., 'customer_processing_order').
- $email(\WC_Email)
- The WooCommerce email object.
Changelog
| Since 10.5.0 | Introduced. |
Where the hook is called
woocommerce_email_content_post_data
woocommerce/src/Internal/EmailEditor/WCTransactionalEmails/WCTransactionalEmailPostsGenerator.php 195
$filtered_post_data = apply_filters( 'woocommerce_email_content_post_data', $post_data, $email_type, $email );