Created
November 28, 2018 14:52
-
-
Save nikitasinelnikov/a3828b7ae6cd19305a07e02f3a159d9c to your computer and use it in GitHub Desktop.
Redirect to selected language page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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