You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a cron job which sends a email when certain conditions are met.
For some reason the string in Dutch (which is the default language) shows 'normally', while the English string is escaped/transformed in some way, making it unreadable/not showing.
The cron job works without issues, which is the function below. SHown for reference.
function sd_cron_remind_user_eot() {
$users = [ 59, 73 ]; // just some random user ids for example
foreach ( $users as $user ) {
// stored preferred language for user. Can be NL | EN (is always set)
$preferred_language = get_user_meta( $user_id, 'sd8_preferred_language', true );
if ( ICL_LANGUAGE_CODE != $preferred_language ) {
if ( 'nl' == ICL_LANGUAGE_CODE ) {
add_filter( 'acf/settings/current_language', function() {
return $preferred_language;
} );
} elseif ( $preferred_language == ICL_LANGUAGE_CODE ) {
add_filter( 'acf/settings/current_language', function() {
return 'nl';
} );
}
}
// get subject from ACF fields
$email_subject = get_field( 'sd_eot_reminder_email_subject', 'option' );
$email_message = get_field( 'sd_eot_reminder_email_company', 'option' );
// switch back to default language
add_filter( 'acf/settings/current_language', function () {
global $sitepress;
return $sitepress->get_default_language();
} );
// if user has not been informed yet
if ( false == get_user_meta( $user_id, 'sd8_informed_eot', true ) ) {
// if user has not set the setting to not receive email
if ( false == get_user_meta( $user_id, 'no_emails', true ) ) {
error_log($email_subject);
// This outputs correctly every time (in both languages)
do_action( 'sd_email_user', $user_id, false, $email_subject, $email_message, $preferred_language );
// hook to trigger email function (see below)
}
}
}
}
add_action( 'sd_orders_eot_reminder', 'sd_cron_remind_user_eot' );
do_action( 'sd_email_user' ) triggers the function below.
I have a cron job which sends a email when certain conditions are met.
For some reason the string in Dutch (which is the default language) shows 'normally', while the English string is escaped/transformed in some way, making it unreadable/not showing.
The cron job works without issues, which is the function below. SHown for reference.
do_action( 'sd_email_user' )
triggers the function below.Site lang: NL/EN + User lang: NL
Correct subject in correct language
See image below.
![Screenshot 2020-10-07 at 21 01 27](https://user-images.githubusercontent.com/4508731/95377312-af343f00-08e2-11eb-97c1-469bc45b7d0a.png)
Site lang: NL/EN + User lang: EN
Escaped subject
See image below.
![Screenshot 2020-10-07 at 21 04 25](https://user-images.githubusercontent.com/4508731/95377339-b6f3e380-08e2-11eb-944c-8c6820447aae.png)
My setup
EDIT: not sure if this is actually caused by Mailhog or by Phpmailer. Will also raise it as ticket there.
The text was updated successfully, but these errors were encountered: