Skip Navigation

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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 -
- - - - - - -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 3 replies, has 2 voices.

Last updated by Waqas Bin Hasan 1 year, 5 months ago.

Assisted by: Waqas Bin Hasan.

Author Posts
January 15, 2024 at 3:12 am #15182829

sinounC-2

Hey there,

We were using the LoginWP plugin and redirecting different user roles to different pages after login. However, the user is not being redirected to the correct language page after login.

We have now removed the LoginWP plugin and our developer has added the following code snippet to redirect users to different welcome pages:

function form_login_redirect( $redirect_to, $request, $user ) {
//is there a user to check?
global $user;
if ( isset( $user->roles ) && is_array( $user->roles ) ) {
if ( in_array( 'staff', $user->roles ) ) {
return get_permalink(get_page_by_path("office-dashboard"));
}else if ( in_array( 'subscriber', $user->roles ) ) {
return get_permalink(get_page_by_path("user-dashboard"));
}
}
return $redirect_to;
}
add_filter( 'login_redirect', 'form_login_redirect', 1, 3 );

add_action('wp_logout','ps_redirect_after_logout');
function ps_redirect_after_logout(){
wp_redirect( '/member-login' );
exit();
}

However, it's still not working.

Could you please look into this and provide us with a solution?

Thank you!

January 15, 2024 at 12:37 pm #15185174

Waqas Bin Hasan
WPML Supporter since 05/2014

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting the support.

Can you please explain what these logins are about? I mean are these WP Admin logins or some kind of member logins on the frontend?

Regards.

January 15, 2024 at 7:16 pm #15186745

sinounC-2

Hi,

Thanks for getting back to me. As I mentioned in my original post, that we redirect different user roles to different pages after login.

We are currently using the Elmentor login widget to enable our users to log in. You can access the login page through the following link: hidden link.

Most of these are subscriber accounts that register on the website via a WPForms registration form, and not admin login accounts.

The other type of user role is custom-created i.e. "Staff", however we create these accounts manually from the WP backend.

I hope this helps, let me know if you have any other questions.

Thank you!

January 16, 2024 at 4:55 am #15187665

Waqas Bin Hasan
WPML Supporter since 05/2014

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for the details.

The "LoginWP" plugin isn't on our compatibility list (https://wpml.org/plugin/) but you've removed it so that's not in question.

The custom coding support is also out of scope of this forum.

However, since you mentioned you're using Elementor's login widget and we can look into that - as long as it offers the intended purposes (but not working as expected). I am not sure much about it.

Is this possible for you to reproduce the same thing on this fresh Sandbox site hidden link ? Just use the minimal possible setup with simple examples. It is a fresh installation with WPML plugins uploaded (not installed or active). You can upload your theme and plugins here and setup as needed.

You can use this plugin https://wordpress.org/plugins/download-plugins-dashboard/ to enable downloadable links for plugins and themes in Plugins and Themes pages respectively. Then you can upload in the sandbox via Plugins/Themes -> Add New.

Please take your time and reply when the site is ready. Once you are able to reproduce the issue, please write down detailed steps about how one can reproduce the issue on another fresh installation.

See https://wpml.org/faq/how-to-reproduce-issues-and-share-them-with-wpml-support/ for details.

The topic ‘[Closed] Elementor – Not redirecting to the correct language after login’ is closed to new replies.