wcml_user_switch_language

Hook fired when the user changes the site language.

Description

do_action( 'wcml_user_switch_language', (string) $lang_from, (string) $lang_to, (string) $referer_url ); 

Parameters (3)

0. $lang_from (string)
The previous language
1. $lang_to (string)
The new language
2. $referer_url (string)
The referer url.

Usage

To run the hook, copy the example below.
  1. // run the action 
  2. do_action( 'wcml_user_switch_language', $lang_from, $lang_to, $referer_url ); 
The following example is for adding a hook callback.
  1. // define the wcml_user_switch_language callback 
  2. function action_wcml_user_switch_language( $lang_from, $lang_to, $referer_url ) { 
  3. // make action magic happen here... 
  4. }; 
  5.  
  6. // add the action 
  7. add_action( 'wcml_user_switch_language', 'action_wcml_user_switch_language', 10, 3 ); 
To remove a hook callback, use the example below.
  1. // remove the action 
  2. remove_action( 'wcml_user_switch_language', 'action_wcml_user_switch_language', 10, 3 ); 

Defined (1)

The action is defined in the following location(s).

/inc/wcml-switch-lang-request.php  
  1. do_action( 'wcml_user_switch_language', $lang_from, $lang_to, $referer_url );