Translated New User emails

Krum has written an excellent plugin (KC s2M+WPML) that exposes s2’s custom field labels and email texts to the WPML string translation table. Translation of the custom email fields works great. However new user emails are always sent as English, even though they have been translated in WPML. WPML support has identified the problem as an incompatibility in S2member. Below is their reply to me, can someone from s2 please assist.

"I can replicate the issue on my local server, it seems that it is a compatibility issue, the plugin s2Member is not listed at our compatibility list: https://wpml.org/documentation/plugins-compatibility, we may need the help of the plugin author to help us to know where is the code snippet that he use to send the mail for the clients, we have some documents to help sending translated emails: https://wpml.org/documentation/support/sending-emails-with-wpml/ we can also ask the client to join our Go Global program: https://wpml.org/documentation/theme-compatibility/go-global-program/ "

After receiving no assistance, we decided to customize the new user notifications in wordpress using the pluggable wp_new_user_notification function. After we completed that, WPML support was able to provide the following information. I include for anyone running into the issue in the future. We did not test this filter, as we already had another solution in place:

I found S2Member plugin loading option too early even when WPML is not ready! And storing them into a global variable then using everywhere thus WPML did get any chance to translate it.
Luckily I found a filter which allows me to alter the email message thus I used it and made a snippet so we can translate the message!
Please add this to your theme functions.php file

add_filter('ws_plugin__s2member_welcome_email_msg', function($msg){
    $options = get_option('ws_plugin__s2member_options');
    if (!empty($options['new_user_email_message'])) {
        return $options['new_user_email_message'];
    }
    return $msg;
});
1 Like

Hi Glen

I encountered a similar problem trying to modify the email that is being sended when a user upgrade her membership.
However, I did not understand what I to do with the $ msg variable, do I want the text I want directly before the “return” or do I have to create a “gettext” function?

Sorry for my bad english.

Thanks
Francesco