Can it translate on Login?
-
Hi!
Awesome plugin! It works perfectly and is so easy to use. Thank you!!
I’d like to run the translation when the user logs in (because I have user meta where they have specified their preferred language). I can’t seem to get it to work.
Note: I have enabled the floating language selector, but hid it in CSS. I have a button that toggles between “English” & “Spanish”, which works fine.
function my_login($login) {
$user_language = get_user_meta( $user->ID, ‘language’, true );
?>
<script type=”text/javascript”>
if ( <?php $user_language ?> == “Spanish”) {
doGTranslate(‘en|es’);
}
else {
doGTranslate(‘es|en’);
}
</script>
<?php }add_action( ‘wp_login’, ‘my_login’, 1);
- The topic ‘Can it translate on Login?’ is closed to new replies.