Skip to content

Instantly share code, notes, and snippets.

@nikitasinelnikov
Created November 28, 2018 14:52
Show Gist options
  • Save nikitasinelnikov/a3828b7ae6cd19305a07e02f3a159d9c to your computer and use it in GitHub Desktop.
Save nikitasinelnikov/a3828b7ae6cd19305a07e02f3a159d9c to your computer and use it in GitHub Desktop.
Redirect to selected language page
function um_custom_login_redirect_secondary_language( $user_id ) {
if ( UM()->external_integrations()->is_wpml_active() ) {
global $sitepress;
$language_code = $sitepress->get_current_language();
if ( $language_code == 'fi' ) {
if ( user_can( $user_id, 'subscriber' ) || user_can( $user_id, 'um_premium-subscribers' ) || user_can( $user_id, 'um_trial-expired' ) ) {
$redirect = '/fi/palveluntarjoajia-etusivu/';
exit( wp_redirect( $redirect ) );
} elseif ( user_can( $user_id, 'customer' ) ) {
$redirect = '/fi/asiakas-etusivu/';
exit( wp_redirect( $redirect ) );
}
}
}
}
add_action( 'um_on_login_before_redirect', 'um_custom_login_redirect_secondary_language' );
@ikergurenet
Copy link

Hi,

Thank you for your contribution, could you explain to me where to put this code to work, since I have done tests and I can not make it work.

Thank you so much

@nikitasinelnikov
Copy link
Author

Hi @ikergurenet

You could insert this code to your theme's functions.php file.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment