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

  • Home
  • SEARCH
  • 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 6962215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:37:50+00:00 2026-05-27T15:37:50+00:00

function Mymodule_user($op,&$edit, &$account, $category = NULL) { switch ($op) { case ‘register’: $result =

  • 0
function Mymodule_user($op,&$edit, &$account, $category = NULL) {
  switch ($op) {
    case 'register':
      $result = db_query("SELECT id,name FROM {sites} ORDER BY name");
      while($row=db_fetch_array($result)) {
        $sites[$row['id']] = $row['name'];
      }

      $form['site_select'] = array(
        '#type' => 'select',
        '#title' => t('Select your site'),
        '#options' => $sites,
      )
      return $form;

    case 'insert':
      //How to take the $form values from above and use in my query to
      //write to my own table while writing to the standard 'users' table?
      db_query("INSERT INTO {another_table} (site_name) VALUES ('%s')",
               $form['site_select']);
);

When the user hits the SUBMIT button when creating a standard Drupal account, how do I pass my custom field value of $form[‘site_select’] to my case ‘insert’ so that I can write this to ‘another_table’. The regular user data such as username and password needs to continue to write to the default ‘users’ table.

Q: Why not just let Drupal serialize and save your data to the ‘users’ table in the ‘data’ field as it normally does?

A: Because I want to be able to AJAX-ify and use autocomplete in another Drupal form, as well as query specific custom fields in MySQL. MySQL cannot serialize/unserialize. For example, “SELECT DISTINCT site_name FROM another_table”

  • 1 1 Answer
  • 0 Views
  • 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-27T15:37:51+00:00Added an answer on May 27, 2026 at 3:37 pm

    You’re probably gonna want to alter the user_register form in order to add your own callback function to that form’s #submit property, like:

    <?php
    /**
     * Implementation of hook_form_FORMID_alter().
     * @param $form
     * @param $form_state
     * @return void
     */
    function MYMODULE_form_user_register_alter(&$form, &$form_state) {
      $form['#submit'][] = 'MYMODULEs_own_register_submit_callback_func';
    }
    

    And then in the callback you’re going to have $form_state filled with whatever the user filled into the form (including the value for the extra site_select field element which you added in your hook_user implementation):

    <?php
    function MYMODULEs_own_register_submit_callback_func(&$form, &$form_state) {
      // Do stuff with $form_state['values'], i.e $form_state['values']['site_select'], etc.
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

function get_total_adults() { $sql = SELECT SUM(number_adults_attending) as number_of_adults FROM is_nfo_rsvp; $result = mysql_query($sql)
I've this mail function in my custom module function mymodule_mail($key, &$message, $params) { switch
Function FillAdminAccount() As Boolean FillAdminAccount = True Try SQLconn.ConnectionString = connect timeout=9999999; & _
function check(id){ var _id = document.getElementById(id); url = test.php?check=1&id= + _id; } i want
I m trying get Best Seller option in select box at Category product listing.
I have a simple form: function mymodule_test_form(&$form_state, $nid) { form['submit'] = array( '#type' =>
I have the folowing code: function checkPermission(user) { var result = 'default'; $.get('/mymodule/checkPermission.php?user=' +
Using the following code: function mymodule_menu_alter(&$items) { if (isset($items['node/add/page'])) { $items['node/add/page']['access arguments'] = FALSE;
function returnsAnArray () { return array ('test'); } echo returnsAnArray ()[0]; generates a syntax
function Submit_click() { if (!bValidateFields()) return; } function bValidateFields() { /// <summary>Validation rules</summary> ///

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.