0

I am using drupal 7 built in form name user_register_form, when clicked on submit or save button I want to store the value of uid column value and status value (if the request is active or blocked) to be stored in another table? How can I implement this , can anybody please guide me ..

UPDATED My table name is expiry_user, expiry_status and expiry_uid are two columns in my table

function mymodule_user_insert(&$edit, $account, $category)
{
db_insert('expiry_user')->fields(array(
'expiry_status' => $account['status'],
'expiry_uid' => $account->uid,
))->execute();
}

1 Answer 1

0

Use hook_user_insert() to take action on the user account after creation:

function mymodule_user_insert(&$edit, $account, $category) {
  //@TODO: use $account->uid & $account->status to do stuff
}
4
  • Thanku @shawn, I have updated my answer, is this the right way?
    – nomeer
    May 9, 2015 at 6:58
  • I don't see anything wrong there. FYI: you can use drupal_write_record() instead if you've defined expiry_user with hook_schema.
    – Shawn Conn
    May 9, 2015 at 7:14
  • I manually created my table in database,as I am using drupal's built in form name user_register_form so may I replace the name of my_module in the above function to this form name?
    – nomeer
    May 11, 2015 at 10:42
  • yes, in order to invoke the hook in your module you need to replace "mymodule" with the machine name of your module.
    – Shawn Conn
    May 11, 2015 at 16:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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