user_preferred_language

Versions
6 – 7
user_preferred_language($account, $default = NULL)

Get the language object preferred by the user. This user preference can be set on the user account editing page, and is only available if there are more than one languages enabled on the site. If the user did not choose a preferred language, or is the anonymous user, the $default value, or if it is not set, the site default language will be returned.

Parameters

$account User account to look up language for.

$default Optional default language object to return if the account has no valid language.

▾ 5 functions call user_preferred_language()

contact_mail_user_submit in modules/contact/contact.pages.inc
Process the personal contact page form submission.
locale_user in modules/locale/locale.module
Implementation of hook_user().
system_send_email_action in modules/system/system.module
Implementation of a configurable Drupal action. Sends an email.
_update_cron_notify in modules/update/update.fetch.inc
Perform any notifications that should be done once cron fetches new data.
_user_mail_notify in modules/user/user.module
Conditionally create and send a notification email when a certain operation happens on the given user account.

Code

modules/user/user.module, line 2132

<?php
function user_preferred_language($account, $default = NULL) {
  $language_list = language_list();
  if ($account->language && isset($language_list[$account->language])) {
    return $language_list[$account->language];
  }
  else {
    return $default ? $default : language_default();
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.