php - Wordpress login redirect user based on language -


i have multilanguage wordpress membership site, s2member , wpml plugins.

an example login page in portuguese is: http://example.com/wp-login?lang=pt-br

i want redirect users after login portuguese welcome page, , not default welcome page english.

is there way add parameter login page in wordpress? if so, how can access parameter redirect?

took me while how solved it.

i have field in database language of each user.

i added functions.php:

add_action( 'wp', 'analyze_form_submit' );  function analyze_form_submit() {      global $current_user;      if (is_page(86)) {  // 86 welcome page after login in case         $affil_id =  $current_user->user_login;        $query="select lang affil affil_id=:affil_id";        $stmt = $conn->prepare($query);        $stmt->bindparam(':affil_id', $affil_id, pdo::param_str);        $stmt->execute();         $row = $stmt->fetch(pdo::fetch_assoc);         $redirect = "http://example.com/welcome?lang=";         switch($row['lang']) {           case "eng" : $redirect .= "en"; break;           case "heb": $redirect .= "he"; break;           case "es" : $redirect .= "es"; break;           case "br" : $redirect .= "pt-br"; break;           default   : $redirect .= "pt-br";         };         wp_redirect( $redirect );        exit;   }; }; 

i hope in future.


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -