Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
If you're trying to register as a vendor on a Hebrew website using an English registration form and the Email Verification Code sent to you is aligned to the right instead of the left, this might be due to the language settings affecting the email styling.
Solution:
We recommend switching the language of your emails before sending them. You can use the

wpml_switch_language_for_email

hook to adjust the language settings for your emails. More details on this hook can be found here: https://wpml.org/wpml-hook/wpml_switch_language_for_email/

Additionally, you can modify the email template directly. Open the file at

.../wp-content/plugins/wc-multivendor-membership/views/emails/email-verification.php

. Replace the existing WooCommerce email header action with a new block that switches the language context based on the user's email. Here's the code you should use:

// Workaround for compsupp-7719
// Workaround for compsupp-7719
// Switch language context
if( apply_filters( 'wcfm_allow_wpml_email_translation', true ) ) {
    do_action('wpml_switch_language_for_email', $user_email);
}
 
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo( 'charset' ); ?/>" />
        <meta content="width=device-width, initial-scale=1.0" name="viewport"/>
        <title><?php echo get_bloginfo( 'name', 'display' ); ?></title>
    </head>
    <body <?php echo is_rtl() ? 'rightmargin' : 'leftmargin'; ?>="0" marginwidth="0" topmargin="0" marginheight="0" offset="0">
        <table width="100%" id="outer_wrapper">
            <tr>
                <td><!-- Deliberately empty to support consistent sizing and layout across multiple email clients. --></td>
                <td width="600">
                    <div id="wrapper" dir="<?php echo is_rtl() ? 'rtl' : 'ltr'; ?>">
                        <table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%">
                            <tr>
                                <td align="center" valign="top">
                                    <div id="template_header_image">
                                        <?php
                                        $img = get_option( 'woocommerce_email_header_image' );
 
                                        if ( $img ) {
                                            echo '<p style="margin-top:0;"><img src="' . esc_url( $img ) . '" alt="' . esc_attr( get_bloginfo( 'name', 'display' ) ) . '" /></p>';
                                        }
                                        ?>
                                    </div>
                                    <table border="0" cellpadding="0" cellspacing="0" width="100%" id="template_container">
                                        <tr>
                                            <td align="center" valign="top">
                                                <!-- Header -->
                                                <table border="0" cellpadding="0" cellspacing="0" width="100%" id="template_header">
                                                    <tr>
                                                        <td id="header_wrapper">
                                                            <h1 style="text-align: <?php echo is_rtl() ? 'right' : 'left'; ?>"><?php echo esc_html( $email_heading ); ?></h1>
                                                        </td>
                                                    </tr>
                                                </table>
                                                <!-- End Header -->
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="center" valign="top">
                                                <!-- Body -->
                                                <table border="0" cellpadding="0" cellspacing="0" width="100%" id="template_body">
                                                    <tr>
                                                        <td valign="top" id="body_content">
                                                            <!-- Content -->
                                                            <table border="0" cellpadding="20" cellspacing="0" width="100%">
                                                                <tr>
                       
</tr></table></td></tr></table></td></tr></table></td></tr></table></div></td></tr></table></body></html>

Ensure to set the text alignment in the HTML body of the email template to respect the left or right text direction based on the language context. At the end of the file, add the following code to switch the language back:

<?php
// switch language back
	if( apply_filters( 'wcfm_allow_wpml_email_translation', true ) ) {
		do_action('wpml_restore_language_from_email');
	}
?>

If this solution does not resolve your issue or seems irrelevant due to updates or differences in your case, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If needed, please open a new support ticket at WPML support forum for further assistance.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Tagged: 

This topic contains 8 replies, has 3 voices.

Last updated by Dražen 2 weeks, 6 days ago.

Assisted by: Dražen.

Author Posts
November 15, 2024 at 10:48 am #16405500

rayaA

Background of the issue:
I am trying to register as a vendor on a Hebrew website using the English registration form found here: hidden link. An Email Verification Code is sent to the user, and I understand from the WCFM developers that the email is sent using the WooCommerce mailer (WC()->mailer()), which handles the styling, including text alignment.

Symptoms:
The Email Verification Code that is sent to the user in English is aligned to the right instead of the expected left alignment.

Questions:
Why is the Email Verification Code aligned to the right instead of the left?
How can I fix the alignment issue for the Email Verification Code?

November 15, 2024 at 4:44 pm #16409425

Andrey
Supporter

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+02:00)

While one of my teammates handles your ticket, I'll provide you with some initial debugging steps.

I suspect that when you send the emails, the language is still set to Hebrew, likely causing WooCommerce to apply the appropriate styles.

I recommend switching the language of your emails before sending them. Here is the wpml_switch_language_for_email hook that you can check: https://wpml.org/wpml-hook/wpml_switch_language_for_email/

Hook wpml_switch_language is also available: https://wpml.org/wpml-hook/wpml_switch_language/

- WPML API: https://wpml.org/documentation/support/wpml-coding-api/wpml-hooks-reference/

- WCML API: https://wpml.org/documentation/related-projects/woocommerce-multilingual/wcml-hooks-reference/

I hope this helps.

November 19, 2024 at 8:58 am #16418151

rayaA

Thank you for commenting. From your answer it is unclear to me if one of your teammate will handle this ticket. Is this the case? Should I wait more for someone to respond??

What am I supposed to do with the hooks that you provided?

Please have a look at the attached image, this is the email being sent when a user registers as a vendor using the *Hebrew* registration form found here:
hidden link
As you can see, the email is in Hebrew and aligned correctly to the right.

As described in the ticket above, when using the English registration form (hidden link), the English version is being sent but aligned to the the right (incorrect). So you can see that the correct language is being used (the text of the email is English) but the styling is incorrect. So I do not understand why you think that the language is still set to Hebrew, when the form itself is in English, the language switcher shows that it is on English (the Hebrew flag is shown because it will show the opposite language), and the email that is sent is sent in English.

1.jpg
November 20, 2024 at 7:41 am #16422497

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+01:00)

Hello,

Can you please try next:

- Make sure you have a backup.
- Disable all other plugins and leave active only WPML and WCFM plugins
- Switch to WP default theme
- Check if the issue still happens.
- Check if the issue still happens when you try it in private window / not logged in

Let me know how it goes.

Regards,
Drazen

November 25, 2024 at 6:09 am #16437839

rayaA

I created a staging environment for this.
- Theme is Twenty Twenty-Three.
- WooCommerce plugin has to stay active because WCFM is using it. WP Mail SMTP plugin also has to stay active otherwise the emails will not reach at all. All other plugins are deactivated.
- The issue still persists, when logged out, and trying from a different browser and from a private window.

November 25, 2024 at 6:58 am #16437928

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+01:00)

Hello,

thanks for testing and getting back.

It could be that this is a new bug that is happening, in order to check and confirm I have created a test site. Can you please install WCFM, setup WPML, and test if the same issue happens. Please share steps with me what have you done.

You can check outgoing emails via email log plugin that I added.

- hidden link

You do not need to waste time creating some content or website, just form where we can see the issue would be enough.

Thanks
Drazen

November 26, 2024 at 4:56 pm #16446323

rayaA

The issue is reproducible in this environment.

I activated the WooCommerce, Set up the WPML (main site language is Hebrew), Installed the WCFM plugin, set it up. The activation email is not being sent. So I also installed Select WP Mail SMTP and set it up. Now the activations emails are being sent correctly.

Steps to reproduce:
Go to hidden link
Enter an email address
Click on the next field
You'll see a prompt saying that an activation email has been sent
Go to inbox of the email that you typed in, and see that the email received is aligned right to left although the registration form was sent from the English form (note the /en/ in the address of the form).

November 27, 2024 at 8:36 am #16447941

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+01:00)

Hello,

thanks for getting back and taking the time to reproduce.

I have checked and could see you have not enabled WCML, WPML String translation, or translated pages. I have done it and to be able to confirm the issue. I also see to be able to reproduce this issue it is needed to enable the Email Verification option from store settings.

In short, I was able to confirm and reproduce the issue after all, so this ticket is now escalated to our compatibility team.

I will update you when I have some news.

Regards,
Drazen

December 2, 2024 at 2:25 pm #16466829

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+01:00)

Hello,

please try next workaround:

Workaround
Open .../wp-content/plugins/wc-multivendor-membership/views/emails/email-verification.php

Look for line 16

Replace:

do_action( 'woocommerce_email_header', $email_heading, $email );
?>

With:

// Workaround for compsupp-7719
// Switch language context
if( apply_filters( 'wcfm_allow_wpml_email_translation', true ) ) {
	do_action('wpml_switch_language_for_email', $user_email);
}

?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo( 'charset' ); ?>" />
		<meta content="width=device-width, initial-scale=1.0" name="viewport">
		<title><?php echo get_bloginfo( 'name', 'display' ); ?></title>
	</head>
	<body <?php echo is_rtl() ? 'rightmargin' : 'leftmargin'; ?>="0" marginwidth="0" topmargin="0" marginheight="0" offset="0">
		<table width="100%" id="outer_wrapper">
			<tr>
				<td><!-- Deliberately empty to support consistent sizing and layout across multiple email clients. --></td>
				<td width="600">
					<div id="wrapper" dir="<?php echo is_rtl() ? 'rtl' : 'ltr'; ?>">
						<table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%">
							<tr>
								<td align="center" valign="top">
									<div id="template_header_image">
										<?php
										$img = get_option( 'woocommerce_email_header_image' );

										if ( $img ) {
											echo '<p style="margin-top:0;"><img src="' . esc_url( $img ) . '" alt="' . esc_attr( get_bloginfo( 'name', 'display' ) ) . '" /></p>';
										}
										?>
									</div>
									<table border="0" cellpadding="0" cellspacing="0" width="100%" id="template_container">
										<tr>
											<td align="center" valign="top">
												<!-- Header -->
												<table border="0" cellpadding="0" cellspacing="0" width="100%" id="template_header">
													<tr>
														<td id="header_wrapper" >
															<h1 style="text-align: <?php echo is_rtl() ? 'right' : 'left'; ?>"><?php echo esc_html( $email_heading ); ?></h1>
														</td>
													</tr>
												</table>
												<!-- End Header -->
											</td>
										</tr>
										<tr>
											<td align="center" valign="top">
												<!-- Body -->
												<table border="0" cellpadding="0" cellspacing="0" width="100%" id="template_body">
													<tr>
														<td valign="top" id="body_content">
															<!-- Content -->
															<table border="0" cellpadding="20" cellspacing="0" width="100%">
																<tr>
																	<td valign="top">
																		<div id="body_content_inner" style="text-align: <?php echo is_rtl() ? 'right' : 'left'; ?>">

And add the following code at the end of the file (around line 88)

<?php
// switch language back
	if( apply_filters( 'wcfm_allow_wpml_email_translation', true ) ) {
		do_action('wpml_restore_language_from_email');
	}
?>

It should work fine, I have tested it also on our test site.

Regards,
Drazen