After long searches I can not find a hook to filter the subject and the message for email sent to the customer when they reset their password in WooCommerce. Is there one for that?
I need to remove (or replace) the site title from the default Password Reset Request for {site_title}
subject, the same for the message, without touching the templates.
I found the WC_Email_Customer_Reset_Password class, but I don't see a filter there.
With the help of @7uc1f3r I figured out how to solve my problem. For the email subject I used the woocommerce_email_subject_customer_reset_password
filter and for the email content the woocommerce_mail_content
filter, both you can find here and here.
/** Filter the subject of reset password email notification **/
add_filter( 'woocommerce_email_subject_customer_reset_password', function( $subject ) {
// woocommerce_mail_content will fire only on customer password reset
add_filter( 'woocommerce_mail_content', 'wc_retrieve_password_message' );
$subject = 'Password Reset Request';
return $subject;
} );
/** Filter the content of reset password email notification **/
function wc_retrieve_password_message( $message ) {
$blogname = get_option( 'blogname' );
if( str_contains( $message, $blogname ) ) {
$message = str_replace( $blogname, home_url(), $message );
}
return $message;
}