Home›Support›English Support›[Resolved] Customizing the Login URL for Different Languages in BuddyBoss Theme
[Resolved] Customizing the Login URL for Different Languages in BuddyBoss Theme
This thread is resolved. Here is a description of the problem and solution.
Problem:
Client is attempting to redirect users to the appropriate language-specific login page when clicking "Login" in the Header Navigation Menu of the BuddyBoss theme. The default login URL always points to wp-login.php and does not account for different languages.
Solution:
We recommend saving the current language to a variable using the wpml_current_language hook, which returns the language code of the active language. Then, set conditions for each language to change the returned URL accordingly.
// Get the current language code
$current_language = apply_filters('wpml_current_language', null);
// Check if the current language is English
if ($current_language == 'en') {
// Redirect to the English login page
} else {
// Redirect to the login page of other languages
}
If this solution does not seem relevant to your issue, please feel free to open a new support ticket in the WPML support forum.
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.
TELL US WHAT YOU ARE TRYING TO DO?
Attempting to have the BuddyBoss Theme "Login" function redirect Users to the appropriate language (English/Spanish) login Page when clicking "Login" in the Header Navigation Menu of the BuddyBoss theme. Here is a video describing exactly what we are struggling with: hidden link
IS THERE ANY DOCUMENTATION THAT YOU ARE FOLLOWING?
Yes: hidden link
The BuddyBoss theme has a "Login" and "SignUp" button that come default with the theme (very convenient!) but the LOGIN URL always points to wp-login.php and cannot be customized (the sign up button actually can be customized but not the login URL). If we want to use another page as our default login page instead of wp-login.php, by default the platform does not have this option. However, BuddyBoss does allow us to use the following function code:
That code works great except that it redirects ALL LANGUAGES to the English /login/ page. So I think my question is, "Do you guys know of a way to have that code above be mindful of if they are on biblicalevangelism.com or biblicalevangelism.com/es and "keep" the /es/ when redirecting to the login page?
My thanks ahead of time for even thinking this through with me! I'm kinda surprised other BuddyBoss/WPML Users haven't run into this already, but for the moment, I couldn't find anything. I did find what appeared to be a similar WPML Support Ticket here (https://wpml.org/forums/topic/login-page-not-redirecting-to-correct-language-in-buddyboss-2/) but couldn't get that function to do anything as you'll see in the video above.
IS THERE A SIMILAR EXAMPLE THAT WE CAN SEE?
Here is a screen recording of me demonstrating the issue: hidden link
WHAT IS THE LINK TO YOUR SITE?
biblicalevangelisml.com (biblicalevangelism.com/es)
It will return the language code of the active language.
Then set conditions for each language and change the returned URL accordingly.
// Get the current language code
$current_language = apply_filters('wpml_current_language', null);
// Check if the current language is English
if ($current_language == 'en') {
// Do something for English
} else {
// Do something for other languages
}