Skip to content

Instantly share code, notes, and snippets.

@yehudah
Last active August 29, 2015 14:23
Show Gist options
  • Select an option

  • Save yehudah/d7dfff7fd808c9f50abd to your computer and use it in GitHub Desktop.

Select an option

Save yehudah/d7dfff7fd808c9f50abd to your computer and use it in GitHub Desktop.
Change admin language with wpml "fix"
<?php
global $pagenow;
if ( isset( $_GET['lang'] ) && is_admin() && $pagenow != 'post.php' ) {
$user_id = wp_get_current_user()->ID;
$lang = filter_var( $_GET['lang'], FILTER_SANITIZE_STRING );
update_user_meta( $user_id,'icl_admin_language', $lang );
$url = "http" . (($_SERVER['SERVER_PORT'] == 443) ? "s://" : "://") . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$redirect = esc_url( remove_query_arg( 'lang', $url ) );
wp_redirect( $redirect );
exit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment