vivalis
Forum Replies Created
-
Great, Yuriina. Will you let me know if you consider building this into UM?
By the way, the plug-in I referred to is the “User Access Manager” by Alexander Schneider.
Kind regards, Roger
Dear Veronica,
It’s finally working. Thanks to Google Language Translator and Ultimate Member, I have now a website that is multilingual – incl. multilingual emails. Rather simple and without the complexity of WPML. Love it! It’s really amazing how UM is built with many hooks and classes that are accessible for website creators so that UM can be tweaked and customized in many ways. Really amazing! I’m an even bigger fan of UM now ??
In case someone is looking for a similar solution, here’s how I did it:
1. When the user enters the webpage with registration or account form or when he changes the website language while being on the registration or account page, this JS snippet reads the current website language setting and stores it in a hidden UM field:
// Set user correspondence language from selected website language when entering the form if ($($userCorrLang).val()=='') { setTimeout(function() {$($userCorrLang).val(get_glt_language('en')).change()}, 500); } // GLT language change event to set user language in case user changes website language $('.nturl').on('click', function() { setTimeout(function() {$($userCorrLang).val(get_glt_language('en')).change()}, 500); });
(get_glt_language(‘default lang’) is a custom function that reads the Google Language Translator cookie “googtrans” from the document cookie.)
2. My UM email templates are stored in the child theme in an admin and several language folders:
– Email templates for admin notifications: child-theme/ultimate-member/email/_admin
– Email templates for emails to users/members: child-theme/ultimate-member/email/<language> (a folder for each language, e.g. en)3. Instruct UM to send emails from the above _admin and language folders, the language depending on the language setting in the recipient’s UM user data (the field that was filled in step 1), by using the UM’s um_email_template_path filter:
add_filter( 'um_email_template_path', 'my_email_template_path', 10, 3 ); function my_email_template_path( $located, $slug, $args ) { $corr_lang = ''; if (UM()->config()->email_notifications[$slug]['recipient'] == 'admin') { $corr_lang='_admin'; } else { $corr_lang = um_user('user_corr_language'); if (!$corr_lang) { $corr_lang='en'; } } $located = get_stylesheet_directory() . '/ultimate-member/email/' . $corr_lang . '/' . $slug . '.php'; return $located; }
4. Instruct UM to use a subject in the appropriate language by using UM’s um_email_send_subject:
add_filter( 'um_email_send_subject', 'my_email_send_subject', 10, 2 ); function my_email_send_subject( $subject, $key ) { $corr_lang = um_user('user_corr_language'); if (!$corr_lang || UM()->config()->email_notifications[$slug]['recipient'] == 'admin') { return $subject; } switch ([$key, $corr_lang]) { case ['checkmail_email', 'en']: $subject = 'Your new {site_name} account: Please confirm email address'; break; case ['checkmail_email', 'fr']: ... // further cases for all user/member email types and languages } return $subject; }
Thank you, Veronica. I really love the Ultimate Member plug-in, and I highly appreciate your great support!
Kind regards, Roger
Thank you, that sounds promising. However, I’m a bit challenged now and need a bit more help with this.
– Is the my_email_template_path function called everytime UM sends an email?
– To set the right language file/folder, I need to check the language field of the email recipient member via the member id. How does the function have access to the member id of the recipient? Is that in the $args array?Thanks for the link, Veronica. I’ve read the article. Does that mean that multi-language emails out of UM do only work with WPML? Or – if I have the structure as suggested in the article – is there another way of making UM choose the language for a member email based on a language field in the member data?
Sure. This is the output of the code snippet after 1 failed login that counted as 2 attempts in Loginizer:
2023-11-06 16:25:22 user_id 0 WP error code invalid_username, message Fehler: Der Benutzername TestUser1 ist auf dieser Website nicht registriert. Falls Sie über Ihren Benutzernamen unsicher sind, versuchen Sie es stattdessen mit Ihrer E-Mail-Adresse., data stack trace: WP: class-wp-hook.php:312, WP: class-wp-hook.php:334, WP: plugin.php:517, WP: class-wp-error.php:209, WP: class-wp-error.php:66, WP: user.php:166, WP: class-wp-hook.php:310, WP: plugin.php:205, ultimate-member/includes/core/um-actions-login.php:64, WP: class-wp-hook.php:312, WP: class-wp-hook.php:334, WP: plugin.php:517, ultimate-member/includes/core/um-actions-form.php:172, WP: class-wp-hook.php:310, WP: class-wp-hook.php:334, WP: plugin.php:517, ultimate-member/includes/core/class-form.php:670, WP: class-wp-hook.php:310, WP: class-wp-hook.php:334, WP: plugin.php:517, WP: template-loader.php:13 2023-11-06 16:25:22 user_id 0 WP error code user_password, message Das Passwort ist nicht korrekt. Bitte versuchen Sie es erneut., data stack trace: WP: class-wp-hook.php:312, WP: class-wp-hook.php:334, WP: plugin.php:517, WP: class-wp-error.php:209, ultimate-member/includes/core/class-form.php:369, ultimate-member/includes/core/um-actions-login.php:84, WP: class-wp-hook.php:312, WP: class-wp-hook.php:334, WP: plugin.php:517, ultimate-member/includes/core/um-actions-form.php:172, WP: class-wp-hook.php:310, WP: class-wp-hook.php:334, WP: plugin.php:517, ultimate-member/includes/core/class-form.php:670, WP: class-wp-hook.php:310, WP: class-wp-hook.php:334, WP: plugin.php:517, WP: template-loader.php:13 2023-11-06 16:25:22 user_id 0 WP error code invalid_username, message Fehler: Der Benutzername TestUser1 ist auf dieser Website nicht registriert. Falls Sie über Ihren Benutzernamen unsicher sind, versuchen Sie es stattdessen mit Ihrer E-Mail-Adresse., data stack trace: WP: class-wp-hook.php:312, WP: class-wp-hook.php:334, WP: plugin.php:517, WP: class-wp-error.php:209, WP: class-wp-error.php:66, WP: user.php:166, WP: class-wp-hook.php:310, WP: plugin.php:205, ultimate-member/includes/core/um-actions-login.php:64, WP: class-wp-hook.php:312, WP: class-wp-hook.php:334, WP: plugin.php:517, ultimate-member/includes/core/um-actions-form.php:172, WP: class-wp-hook.php:310, WP: class-wp-hook.php:334, WP: plugin.php:517, ultimate-member/includes/core/class-form.php:670, WP: class-wp-hook.php:310, WP: class-wp-hook.php:334, WP: plugin.php:517, WP: template-loader.php:13 2023-11-06 16:25:22 user_id 0 WP error code user_password, message Das Passwort ist nicht korrekt. Bitte versuchen Sie es erneut., data stack trace: WP: class-wp-hook.php:312, WP: class-wp-hook.php:334, WP: plugin.php:517, WP: class-wp-error.php:209, ultimate-member/includes/core/class-form.php:369, ultimate-member/includes/core/um-actions-login.php:84, WP: class-wp-hook.php:312, WP: class-wp-hook.php:334, WP: plugin.php:517, ultimate-member/includes/core/um-actions-form.php:172, WP: class-wp-hook.php:310, WP: class-wp-hook.php:334, WP: plugin.php:517, ultimate-member/includes/core/class-form.php:670, WP: class-wp-hook.php:310, WP: class-wp-hook.php:334, WP: plugin.php:517, WP: template-loader.php:13
Dear Yuriina,
There actually is a plug-in that allows access restrictions on the files itself: User Access Manager. Check it out ?? Maybe you wanna implement something similar in UM.
Kind regards, Roger
Thank you, Dmytro. I’ve implemented it with JS only and a hidden dropdown with the country phone codes ($country_phone_code). If the user changes the country (in $countries_dd), that change triggers the following updates:
– Hidden field with country phone codes is changed to the same as the user selected country (the option label is the phone code).
– Flag and phone code of phone field ($customer_phone) are changed.//change event of user country field ($countries_dd) $($country_phone_code).val($(this).val()).change(); $($customer_phone + ' input').val($($country_phone_code + ' option:selected').text()).change(); $('.iti__selected-flag .iti__flag')[0].className = 'iti__flag iti__' + $($countries_dd).val().toLowerCase();
Thanks for your help!
Kind regards, Roger
Thanks, Veronica. The code snippet for debugging WP redirects and errors didn’t bring any clue.
Dear Kasia,
The website is not online yet. But my question is really simple: How can I change the country of a Forminator phone field by Javascript/jQuery?
Hello @yuriinalivaiko,
Thanks for your reply. I think what you’re describing is not a solution to my question. What I’d like to do: Upload PDFs to the media library (or to another folder) that I can make accessible to members via links in the member area. The members can click on a link to view/download the PDF. Only logged in users can view/download the PDF. How can I do this?
Dear Kris, thanks for your solution. I changed the target.id to 938, the 1st field (country field) to select-5 and the 2nd field (phone field) to phone-1. It doesn’t work because the 2nd field is a phone field, not a select field, and has not select element. I tried to target the .iti__flag-container and the .iti__selected-flag class with the jQuery selector, with no success.
I think I don’t need the add_action. If I know how to programmatically change the country/flag of the phone field, I can trigger the change in the JS event of the country field. So, the big question is: Which element is to target in a phone field in order to change the country/flag?
Yes, the line?
//add_action('wp_authenticate'...
?is commented in the init.php of my Loginizer installation…Thank you very much, Veronica. This works now and no UM wrong pw message is shown if there’s a Loginizer IP blocked/blacklisted error message. ??
I have the following code to prevent access to the wp login page. Enabling/disabling this code doesn’t have an impact on every failed login try being counted as 2 login attempts in Loginizer. Is there a better way to disable WP login?
add_action('init','custom_login'); function custom_login(){ global $pagenow; if( 'wp-login.php' == $pagenow && $_GET['action']!="logout") { wp_redirect( home_url() ); exit; } }
- This reply was modified 1 year ago by vivalis.
Thank you, Veronica. Your quick support is very appreciated. There remain 1 question and 1 problem:
Question: Do you happen to know why every failed login try in the UM login form counts as 2 login attempts in Loginizer?
Problem: When the IP is blocked or blacklisted, the Loginizer error message about exceeded maximum retries or blacklisted IP appears above the login fields. Problem is that the UM wrong password message also appears IF the password is wrong, but it doesn’t appear if the password is correct. That way, despite the IP being blocked, an attacker can keep trying to discover the correct password (correct pw is found when only Loginizer error message appears, but not the UM wrong pw message).
Dear Saurabh,
Sorry if I wasn’t clear with my question. The situation is actually quite simple: There’s a select field A with alpha-2 country codes (e.g. AT, CH, DE, ES, FR, IT). Then, there’s an international phone field B.
What I’d like to achieve: When the user selects a country in A, I’d like to programmatically select the same country in the phone field B.
Kind regards, Roger