function gravatar_form_alter in Gravatar integration 5
Implementation of hook_form_alter().
File
- ./
gravatar.module, line 126 - Integrates gravatar service for comment user pictures.
Code
function gravatar_form_alter($form_id, &$form) {
// User edit account.
if ($form_id == 'user_edit' && $form['_category']['#value'] == 'account' && isset($form['picture']) && variable_get('user_pictures', 0) && ($account = $form['_account']['#value']) && user_access('use gravatar', $account)) {
// Add the default user picture preview.
if (!isset($form['picture']['current_picture']) && ($picture = theme('user_picture', $account))) {
$form['picture']['current_picture'] = array(
'#value' => $picture,
'#weight' => -10,
);
}
$form['picture']['gravatar_description'] = array(
'#value' => t('If you have a <a href="@gravatar-check">valid gravatar</a> for your e-mail address, it will replace your current user picture in comments.', array(
'@gravatar-website' => url('http://www.gravatar.com/'),
'@gravatar-check' => url('http://en.gravatar.com/site/check/' . $account->mail),
)),
'#access' => !isset($account->gravatar) || $account->gravatar,
);
$form['picture']['gravatar'] = array(
'#type' => 'checkbox',
'#title' => t('Replace my user picture in comments with the gravatar for my e-mail address.'),
'#default_value' => isset($account->gravatar) ? $account->gravatar : 1,
'#access' => user_access('disable own gravatar', $account),
);
}
}