Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 951803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:47:39+00:00 2026-05-15T23:47:39+00:00

I can add an extra field to the registration. What I need to know

  • 0

I can add an extra field to the registration. What I need to know is what step do I need to take to then grab that input and insert it into the user table of drupal. The code below is in my module this adds just a field to the form, but when its submitted it doesnt do anything with the data.

function perscriptions_user($op, &$edit, &$account, $category = NULL){
  if ($op == 'register') {
    $form['surgery_address'] = array (
      '#type' => 'textarea',
      '#title' => t('Surgery Address'),
      '#required' => TRUE,
    );      

     return $form;     
  }

  if ($op == 'update') {
    // …
  }
}
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T23:47:40+00:00Added an answer on May 15, 2026 at 11:47 pm

    As reported in hook_user() documentation:

    $op What kind of action is being performed. Possible values (in alphabetical order):
    – “insert”: The user account is being added. The module should save its custom additions to the user object into the database and set the saved fields to NULL in $edit.
    – “update”: The user account is being changed. The module should save its custom additions to the user object into the database and set the saved fields to NULL in $edit.
    – “validate”: The user account is about to be modified. The module should validate its custom additions to the user object, registering errors as necessary.

    The module needs to create its own database table in hook_install().

    hook_user() could be implemented with the following code, for example:

    function perscriptions_user($op, &$edit, &$account, $category = NULL){
      if ($op == 'register' || ($op == 'form' && $category = 'account')) {
        $form['surgery_address'] = array (
          '#type' => 'textarea',
          '#title' => t('Surgery Address'),
          '#required' => TRUE,
        );
    
        return $form;     
      }
    
      if ($op == 'insert' || $op == 'update') {
        prescriptions_save_user_profile($account->uid, $edit['surgery_address']);
      }
      if ($op == 'validate' && $category == 'account') {
        // Verify the entered values are valid.
        // In this example, the value is contained in $edit['surgery_address'].
      }
    }
    

    prescriptions_save_user_profile() is the function that saves the user profile values in the database. The code checks the category to avoid to show the same form fields in all the tabs shown in the user profile edit form.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to add some extra field to Joomla registration form without using any
Does anyone know of a way in which I can add an extra database
So, the extra field in a queryset can be used to add additional columns
I know one can add event listener for window.error. However when working with Iframes,
I'm trying to implement #field_prefix on a text field so I can add some
I'm developing a registration website and there's a part where I need to add
I have a text field in my model that contains markdown text. I need
I don't think I can actually add a field (column) to an existing IEnumerable.
I can add and remove the last line in my dynamic form and calculate
I can add a normal rightBarButton to my navigation without a problem but now

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.