Implements hook_form_FORM_ID_alter().
function overlay_form_user_profile_form_alter(&$form, &$form_state) {
$account = $form_state['controller']
->getEntity($form_state);
if (user_access('access overlay', $account)) {
$account_data = drupal_container()
->get('user.data')
->get('overlay', $account
->id(), 'enabled');
$form['overlay_control'] = array(
'#type' => 'details',
'#title' => t('Administrative overlay'),
'#weight' => 4,
'#collapsible' => TRUE,
);
$form['overlay_control']['overlay'] = array(
'#type' => 'checkbox',
'#title' => t('Use the overlay for administrative pages.'),
'#description' => t('Show administrative pages on top of the page you started from.'),
'#default_value' => isset($account_data) ? $account_data : 1,
);
}
}