function gravatar_form_user_profile_form_alter in Gravatar integration 7
Same name and namespace in other branches
- 6 gravatar.module \gravatar_form_user_profile_form_alter()
Implements hook_form_FORM_ID_alter().
@todo Improve message shown to user.
File
- ./
gravatar.module, line 249 - Integrates gravatar service for user pictures.
Code
function gravatar_form_user_profile_form_alter(&$form, $form_state) {
if ($form['#user_category'] == 'account' && isset($form['picture']) && variable_get('user_pictures', 0) && ($account = $form['#user']) && user_access('use gravatar', $account)) {
// Add the default user picture preview.
if (!isset($form['picture']['picture_current']) && ($picture = theme('user_picture', array(
'account' => $account,
)))) {
$form['picture']['picture_current'] = array(
'#value' => $picture,
'#weight' => -10,
);
}
if (user_access('disable own gravatar', $account)) {
$form['picture']['gravatar'] = array(
'#type' => 'checkbox',
'#title' => t('If you have a <a href="@gravatar-check">valid Gravatar</a> associated with your e-mail address, use it for your user picture.', array(
'@gravatar-check' => 'http://en.gravatar.com/site/check/' . $account->mail,
)),
'#description' => t('Your Gravatar will not be shown if you upload a user picture.'),
'#default_value' => isset($account->data['gravatar']) ? $account->data['gravatar'] : 1,
'#disabled' => !empty($account->picture),
);
}
else {
$form['picture']['gravatar'] = array(
'#type' => 'item',
'#markup' => t('If you have a <a href="@gravatar-check">valid gravatar</a> associated with your e-mail address, it will be used for your user picture.', array(
'@gravatar-check' => 'http://en.gravatar.com/site/check/' . $account->mail,
)),
'#description' => t('Your Gravatar will not be shown if you upload a user picture.'),
);
}
}
}