WPML switch backend language on language switch

Notice: A non well formed numeric value encountered in /customers/b/b/d/puddinq.com/httpd.www/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118Notice: A non well formed numeric value encountered in /customers/b/b/d/puddinq.com/httpd.www/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119Notice: A non well formed numeric value encountered in /customers/b/b/d/puddinq.com/httpd.www/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118Notice: A non well formed numeric value encountered in /customers/b/b/d/puddinq.com/httpd.www/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119

Since wp 4.7 the backend language is changed by changing the language in your userprofile. Using WPML, if you change the site language or post-, page language, the backend language is not changing. The code below changes the site language when changing the wpml language selector.