Skip to content

Instantly share code, notes, and snippets.

@tanmayk
Last active December 28, 2015 18:59
Show Gist options
  • Save tanmayk/7546777 to your computer and use it in GitHub Desktop.
Save tanmayk/7546777 to your computer and use it in GitHub Desktop.
/**
* Privacy settings form for user.
*/
function privacy_settings_form_callback($form, &$form_state) {
global $user;
$form = array();
$options = array(0 => 'Public', 1 => 'Friends', 2 => 'Private');
$instances = field_info_instances('user', 'user');
foreach ($instances as $field_name => $field_info) {
$form[$field_name] = array(
'#type' => 'select',
'#title' => t('Who can see your ') . $field_info['label'] . ' ?',
'#options' => $options,
'#default_value' => $user->data['privacy_settings'][$field_name],
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
return $form;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment