function _ldap_authentication_form_user_profile_form_alter in Lightweight Directory Access Protocol (LDAP) 8.2
Same name and namespace in other branches
- 7.2 ldap_authentication/ldap_authentication.inc \_ldap_authentication_form_user_profile_form_alter()
- 7 ldap_authentication/ldap_authentication.inc \_ldap_authentication_form_user_profile_form_alter()
alter user editing form (profile form) based on ldap authentication configuration
Parameters
array $form array from user profile:
array $form_state from user profile:
Return value
NULL (alters $form by reference)
1 call to _ldap_authentication_form_user_profile_form_alter()
- ldap_authentication_form_user_profile_form_alter in ldap_authentication/
ldap_authentication.module - Implements hook_form_FORM_ID_alter(). for user_profile_form
File
- ldap_authentication/
ldap_authentication.inc, line 76 - ldap_authentication helper functions
Code
function _ldap_authentication_form_user_profile_form_alter(&$form, $form_state) {
// keep in mind admin may be editing another users profile form. don't assume current global $user
$auth_conf = ldap_authentication_get_valid_conf();
if ($auth_conf && ldap_authentication_ldap_authenticated($form['#user'])) {
if ($auth_conf->emailOption == LDAP_AUTHENTICATION_EMAIL_FIELD_REMOVE) {
$form['account']['mail']['#type'] = 'hidden';
}
elseif ($auth_conf->emailOption == LDAP_AUTHENTICATION_EMAIL_FIELD_DISABLE) {
$form['account']['mail']['#disabled'] = TRUE;
$form['account']['mail']['#description'] = t('This email address is automatically set and may not be changed.');
}
elseif ($auth_conf->emailOption == LDAP_AUTHENTICATION_EMAIL_FIELD_ALLOW) {
// email field is functional
}
if (!ldap_authentication_show_reset_pwd($form['#user'])) {
$form['account']['current_pass']['#disabled'] = TRUE;
if ($auth_conf->ldapUserHelpLinkUrl) {
$form['account']['current_pass']['#description'] = l(t($auth_conf->ldapUserHelpLinkText), $auth_conf->ldapUserHelpLinkUrl);
}
else {
$form['account']['current_pass']['#description'] = t('The password cannot be changed using this website');
}
$form['account']['pass']['#disabled'] = TRUE;
}
}
}