#TRPLINKPROCESSED
-
Hello,
I’m experiencing an issue with TranslatePress that only occurs when using a language other than the site’s default.
Here’s what happens:
When I log in while using a non-default language (e.g., my URL is mydomain.com/lt/login instead of mydomain.com/login), after a successful login I am redirected to the homepage, but the URL ends with #TRPLINKPROCESSED. For example:
mydomain.com/lt/#TRPLINKPROCESSED
If I log in using the default language, everything works normally (mydomain.com/), and no #TRPLINKPROCESSED is added.
Even on unsuccessful login attempts, if I’m using a non-default language, the login page refreshes and #TRPLINKPROCESSED is appended:
mydomain.com/lt/login#TRPLINKPROCESSED
I’ve tried the following troubleshooting steps:
Deactivating all plugins
Switching themes
Clearing all caches
It seems to be related purely to the login redirect handling with TranslatePress.
Has anyone experienced this or know how to fix it?
Thanks in advance!
<?php
// Start PHP session for flash error messages
add_action('init', function () {
if (!session_id()) {
session_start();
}
});
// Process login on template_redirect
add_action('template_redirect', function () {
if (isset($_POST['sev_login_submit'])) {
$username = sanitize_text_field($_POST['sev_login_username']);
$password = $_POST['sev_login_password'];
$remember = !empty($_POST['sev_login_remember']);
$user = get_user_by('login', $username);
$redirect_to = wp_get_referer() ? wp_get_referer() : SEV_LOGIN_URL;
if (!$user) {
$_SESSION['sev_login_error'] = 'invalid_credentials';
wp_safe_redirect($redirect_to);
exit;
}
$creds = [
'user_login' => $username,
'user_password' => $password,
'remember' => $remember,
];
$signed_in = wp_signon($creds);
if (is_wp_error($signed_in)) {
$_SESSION['sev_login_error'] = 'incorrect_password';
wp_safe_redirect($redirect_to);
exit;
}
if (in_array('pending', (array) $signed_in->roles)) {
wp_logout();
$_SESSION['sev_login_error'] = 'pending_verification';
wp_safe_redirect($redirect_to);
exit;
}
// Successful login
wp_safe_redirect(home_url());
exit;
}
});
// Login form shortcode
function sev_login_form()
{
$error_msg = '';
if (!empty($_SESSION['sev_login_error'])) {
$code = sanitize_text_field($_SESSION['sev_login_error']);
switch ($code) {
case 'invalid_credentials':
$error_msg = 'Invalid login credentials.';
break;
case 'incorrect_password':
$error_msg = 'Incorrect password.';
break;
case 'pending_verification':
$error_msg = 'Please verify your email before logging in.';
break;
default:
$error_msg = 'Login failed. Please try again.';
break;
}
unset($_SESSION['sev_login_error']); // Clear flash message
}
ob_start();
?>
<form method="post" class="oceanwp-form">
<?php if ($error_msg): ?>
<div class="alert error">
<?php echo esc_html($error_msg); ?>
</div>
<?php endif; ?>
<div class="form-group">
<label>Username</label>
<input type="text" name="sev_login_username" required class="oceanwp-form-control">
</div>
<div class="form-group">
<label>Password</label>
<input type="password" name="sev_login_password" required class="oceanwp-form-control">
</div>
<div class="form-group">
<label>
<input type="checkbox" name="sev_login_remember" value="1"> Remember Me
</label>
</div>
<div class="form-group">
<button type="submit" name="sev_login_submit" class="oceanwp-button">Log In</button>
</div>
<div class="form-group">
<p>
Don't have an account?
<a href="<?php echo esc_url(SEV_REGISTER_URL); ?>">Register</a><br>
Forgot password?
<a href="<?php echo esc_url(SEV_FORGOT_URL); ?>">Reset password</a>
</p>
</div>
</form>
<?php
return ob_get_clean();
}
add_shortcode('simple_login', 'sev_login_form');
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
You must be logged in to reply to this topic.