Quantcast
Channel: Active questions tagged users - Drupal Answers
Viewing all articles
Browse latest Browse all 468

Can't hide fields in user registration form at new menu path

$
0
0

I have a menu path which rendered User Registration Form. The problem is I did hide fields like "Email", "password" and "status" by setting #access to FALSE. It is not working.

When I have done the same thing in hook_form_alter(), it does work.

This is my code.

/** * Implements hook_menu(). */function MY_MODULE_menu() {  $items['admin/author/create'] = array('title' => t('Author'),'page callback' => 'MY_MODULE_author_form','type' => MENU_CALLBACK,'access callback' => TRUE,  );  return $items;}/** * Author form. */function MY_MODULE_author_form() {  drupal_set_title('Create Author');  // Getting User Register Form  $form = drupal_get_form('user_register_form');   // Change Username to Author Name  $form['account']['name']['#title'] = 'Author Name';  // Exclude User Registeration Elements  $form['account']['mail']['#access'] = FALSE;  $form['account']['pass']['#access'] = FALSE;  $form['account']['status']['#access'] = FALSE;  // The path to which the form will be submitted.  $form['#action'] = url('admin/people/create');   return $form;}

I think I can alter the form in MY_MODULE_author_form().

Is there anything wrong with my code?


Viewing all articles
Browse latest Browse all 468

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>