So here is my situation: users on my site have to fill out a rather large number of fields upon registration. However, after they register, only four (out of about twenty) of these fields need to be changed regularly. I would like to create a separate "edit" page to allow users to modify just these four fields to keep things simple.

  • field_checkbox_a
  • field_checkbox_b
  • field_checkbox_c
  • field_checkbox_d

These fields are all contained in a field group, so ideally the page would show this field group, the four checkboxes inside it, and then have a submit and cancel button, that's it.

I want to do this as a separate page, not in-place editing like the Quick Edit module.

Users still need to be able to access the original edit account page to change their timezone, e-mail address, etc. but I could really use a separate screen to allow them to edit the most common account options.


7 Answers 7


I had the same situation before and handle it with power full druapl feature hook_form_alter, we have 2 forms for user, registration and user edit

  • user_profile_form ( in editing)
  • user_register_form (in registration)

We just need hide your specified fields in edit manner So in your custom module

function yourmodule_form_alter(&$form, &$form_state, $form_id)
    global $user;

    if ($form_id == "user_profile_form") {
       // ym($form);
       // you also can perform this action for specified roles 
        //if (!(in_array('blogger', $user->roles) || in_array('administrator', $user->roles))) {
            // hide other field with this method


After that field exists in registration as you can see below

enter image description here

and not exist (hide) in edit manner

enter image description here

Also you can set them read only instead hiding them with $form['field']['#access'] = FALSE;

And another solution is using field permission module

The Field Permissions module allows site administrators to set field-level permissions to edit, view and create fields on any entity. Features:

  • Enable field permissions on any entity, not just nodes.
  • Role-based field permissions allowing different viewing patterned based on what access the user has.
  • Author-level permissions allow viewing and editing of fields based on who the entity owner is.
  • Permissions for each field are not enabled by default. Instead, administrators can enable these permissions explicitly for the fields where this feature is needed.

As features that this module provides for us anonymous user( un-register user can edit those field and register user only see(readonly manner).


Instead of having two forms, you could use the default one, and add a "Show all the settings" checkbox, such as the following one.

$form['show_all_settings'] = array(
  '#type' => 'checkbox',
  '#title' => t('Show all settings'),

Then, you can alter the form fields you want to show when the checkbox is selected, and include the following property for those form fields.

'#states' => array(
  'invisible' => array(
   ':input[name="show_all_settings"]' => array('checked' => FALSE),

In this way, the users would be able to toggle between a form showing all the setting, and a form showing a minimal set of settings, without to pass from a page to another one.



You can use Profile2 module for that.

  • Create a profile type or use the default main profile.
  • Add those fields to that profile type and set them to be shown on registration form.

So that those fields will be available on the registration form among the other fields from user account. But to edit those fields, the user should go to the profile edit page instead of user edit page.

  • I want to show the four checkboxes on the user edit page and their own custom page; I don't want to remove them from the main user edit page. Dec 19, 2015 at 16:40

Try VBO module, you can create a VBO page, add USER relationship in view, add those fields that available for user to mod, set the Permission. Make sure you select content "belongs" to CURRENT user only (via Contextual Filter)

  • How can I allow the user to edit these fields? VBO lets me display the values, but I need them to be editable. Nov 11, 2012 at 5:47
  • Add vbo field then tick the operation of 'modify entity values' (something like this, can't remember what exactly it is called)
    – gilzero
    Nov 11, 2012 at 8:28
  • Thanks, it is called modify entity values. Unfortunately, this doesn't work for my case, but it may be a useful solution for others. Nov 11, 2012 at 11:33

Based on zhilevan's answer to this question and this question and this discussion on drupal.org, here is the actual code that works for me:

function MYMODULE_menu() {
  $items = array();
  $items['user/editpurposes'] = array(
    'title' => t('Change your purposes'),
    'page callback' => 'MYMODULE_purpose_edit_form',
    'access callback' => TRUE,
    'access arguments' => array('access content'),
    'description' => t('Purpose Edit Form'),
    'type' => MENU_CALLBACK,
  return $items;

function MYMODULE_purpose_edit_form() {
  // Needed to load AJAX.
  module_load_include('inc', 'user', 'user.pages');
  global $user;
  $account = user_load($user->uid); // Load a user object
  $form = drupal_get_form('user_profile_form', $account, 'account', 'purposes');
  return $form;

function MYMODULE_form_user_profile_form_alter(&$form, &$form_state) {
  if(isset($form_state['build_info']['args'][2]) && $form_state['build_info']['args'][2] == 'purposes') {

    // Remove name, email, password, etc.
    $form['account']['#access'] = FALSE;
    // Remove language.
    $form['locale']['#access'] = FALSE;
    $form['timezone']['#access'] = FALSE;
    // Remove various custom fields.
    $form['field_acc_displayname']['#access'] = FALSE;
    $form['field_acc_code_agree']['#access'] = FALSE;

    // Needed to load AJAX.
    form_load_include($form_state, 'inc', 'user', 'user.pages');
  • can I ask why Profile2 was not an option, as I suggested in my answer?
    – Elin Y.
    Dec 18, 2015 at 15:49

I think you should be able to tidy things up a bit with the Field group module, e.g. put fields under different tabs. Common ones under one tab and the rest under another tab.

  • Thanks for this idea, but I'm already using the Field Group module. It's good but I really just want to show four options to the user, not everything. Nov 10, 2012 at 7:55

try this code. and hide other fields u don't want to show.

global $user;
module_load_include('inc', 'user', 'user.pages');
$user_form = drupal_get_form('user_profile_form', $user);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.