Skip to content Skip to sidebar

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

Problem:
If you're experiencing issues with Gravity Forms where the confirmation translation only includes the URL field and ignores the URL parameter field, particularly when switching languages (e.g., from German to English), resulting in missing URL parameters in the redirection.
Solution:
We found that the issue is related to custom coding and the wp-force-login plugin. Specifically, the problem occurs in the

/wp-content/plugins/FHWPLoginRedirect/FHWPLoginRedirect.php

file within the

my_login_page

function, which incorrectly handles URL parameters during redirections for different languages. To resolve this, replace the existing function with the following code:

add_filter('login_url', 'my_login_page', 10, 3);<br />function my_login_page($login_url, $redirect, $force_reauth) {<br />    $request_redirect = '';<br />    if (isset($_GET['redirect_to']) && $_GET['redirect_to'] !== '') {<br />        $request_redirect = wp_unslash($_GET['redirect_to']);<br />    }<br />    $existing_redirect = '';<br />    $login_parts = wp_parse_url($login_url);<br />    if (!empty($login_parts['query'])) {<br />        parse_str($login_parts['query'], $q);<br />        if (!empty($q['redirect_to'])) {<br />            $existing_redirect = $q['redirect_to'];<br />        }<br />    }<br />    $target = $request_redirect ?: ($redirect ?: $existing_redirect);<br />    $target_path = '';<br />    if (!empty($target)) {<br />        $tp = wp_parse_url($target);<br />        $target_path = $tp['path'] ?? '';<br />    } else {<br />        $target_path = wp_parse_url($_SERVER['REQUEST_URI'] ?? '')['path'] ?? '';<br />    }<br />    $is_en = (strpos($target_path, '/en/') === 0)<br />        || (strpos($_SERVER['REQUEST_URI'] ?? '', '/en/') === 0);<br />    $base = $is_en ? home_url('/en/login-registration/') : home_url('/login/');<br />    if (empty($request_redirect) && !empty($target_path)) {<br />        if ($is_en && strpos($target_path, '/en/login-registration/') === 0) {<br />            return $base;<br />        }<br />        if (!$is_en && strpos($target_path, '/login/') === 0) {<br />            return $base;<br />        }<br />    }<br />    if (!empty($target)) {<br />        $base = add_query_arg('redirect_to', $target, $base);<br />    }<br />    if ($force_reauth) {<br />        $base = add_query_arg('reauth', '1', $base);<br />    }<br />    return $base;<br />}

Please implement this solution and verify if it resolves your issue. If this solution does not apply to your case or seems outdated, we 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 further assistance is needed, please open a new support ticket at 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.

Tagged: 

This topic contains 31 replies, has 1 voice.

Last updated by einkaufZ 1 month, 3 weeks ago.

Assisted by: Osama Mersal.

Author Posts
January 15, 2026 at 9:31 am #17732253

Osama Mersal

Hi,

Our 2nd tier support team has found that the issue is related to custom coding and the wp-force-login plugin.
The problem is in: /wp-content/plugins/FHWPLoginRedirect/FHWPLoginRedirect.php in the function my_login_page, which redirects for English to a custom page, and it strips the parameters there.

Replacing the code with the following fixed the issue in our tests:

add_filter('login_url', 'my_login_page', 10, 3);
function my_login_page($login_url, $redirect, $force_reauth) {

    // 1) Pull redirect_to from CURRENT REQUEST (most important when you're on the login page)
    $request_redirect = '';
    if (isset($_GET['redirect_to']) && $_GET['redirect_to'] !== '') {
        // wp_unslash because WP may add slashes in some contexts
        $request_redirect = wp_unslash($_GET['redirect_to']);
    }

    // 2) Pull redirect_to already present in $login_url (sometimes WP already embedded it)
    $existing_redirect = '';
    $login_parts = wp_parse_url($login_url);
    if (!empty($login_parts['query'])) {
        parse_str($login_parts['query'], $q);
        if (!empty($q['redirect_to'])) {
            $existing_redirect = $q['redirect_to'];
        }
    }

    // 3) Decide final target (priority: current request > $redirect > existing in login_url)
    $target = $request_redirect ?: ($redirect ?: $existing_redirect);

    // 4) Decide language based on TARGET path (or fallback to current request URI)
    $target_path = '';
    if (!empty($target)) {
        $tp = wp_parse_url($target);
        $target_path = $tp['path'] ?? '';
    } else {
        $target_path = wp_parse_url($_SERVER['REQUEST_URI'] ?? '')['path'] ?? '';
    }

    $is_en = (strpos($target_path, '/en/') === 0)
        || (strpos($_SERVER['REQUEST_URI'] ?? '', '/en/') === 0);

    $base = $is_en ? home_url('/en/login-registration/') : home_url('/login/');

    // 5) Loop prevention: only suppress redirect_to if the target is *exactly* the login page.
    // IMPORTANT: do NOT trigger this if the user provided redirect_to in the current request.
    if (empty($request_redirect) && !empty($target_path)) {
        if ($is_en && strpos($target_path, '/en/login-registration/') === 0) {
            return $base;
        }
        if (!$is_en && strpos($target_path, '/login/') === 0) {
            return $base;
        }
    }

    // 6) Build final URL with exactly one redirect_to
    if (!empty($target)) {
        $base = add_query_arg('redirect_to', $target, $base);
    }
    if ($force_reauth) {
        $base = add_query_arg('reauth', '1', $base);
    }

    return $base;
}

Please review and let me know whether the code above resolves the issue.

Best regards,
Osama

January 16, 2026 at 7:56 am #17735859

einkaufZ

Hello Osama!

AMAZING AMAZING AMAZING!!!

THANK YOU VERY VERY MUCH!!!

It is working perfectly right now!

Kind regards,

Klaus 🙂