hi I am trying to write a page callback that lets site admin to create a specific type of user. I would like the admin to have the option to create the regular user when he click the add user tab and i would also like to create another tab to create a different type of user, how would I go about doing this? I have create the menu it fine but the callback page is the problem, i tried useing the hook form_user_register_alter as my callback function with the add form element that i wanted but it didn't work.

Comments

vj’s picture

to create another tab at admin/user/user
add this and clear cache.

also in callback you have to create a form and its submit function.

$items['admin/user/user/new'] = array(
    'title' => 'New user add',
    'description' => 'Add different user.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('multipart_new_user_register'),
    'access callback' => TRUE,
    'type' => MENU_LOCAL_TASK,
  );

function multipart_new_user_register (&$form_state) {
  $form = array();
  $form['name'] = array(
      '#type' => 'textfield', 
      '#title' => t('Name'), 
      '#size' => 60, 
      '#maxlength' => 128, 
      '#required' => TRUE,
    );
  $form['pass'] = array(
      '#type' => 'password', 
      '#title' => t('Password'), 
      '#maxlength' => 64, 
      '#size' => 15,
    );
  $form['pass'] = array(
      '#type' => 'password_confirm', 
      '#title' => t('Password'), 
      '#size' => 25,
    );
  $form['mail'] = array(
			'#title' => t('User Mail'),
			'#type' => 'textfield',
			);
  $form['submit'] = array('#type' => 'submit', '#value' => t('Save'));
  

  return $form;
}

function multipart_new_user_register_submit ($form, &$form_state) {
  $users = array();
  $users['values']['name'] = $form_state['values']['name'];
  $users['values']['mail'] = $form_state['values']['mail'];
  $users['values']['pass']['pass1'] = $form_state['values']['pass'];
  $users['values']['pass']['pass2'] = $form_state['values']['pass'];
  $users['values']['op'] = t('Create new account');
  drupal_execute('user_register', $users);
}