3

Is there any way (without using core Profile) to add two fields to the user registration form with Content Type Profile, OR, using Form API to add two fields to save into a content profile node created from user registration?

Is there anyway to intercept user_save while its creating that user and add the fields to the profile node or is there some easier way?

Kevin
  • 13,153
  • 11
  • 60
  • 87

1 Answers1

4

You sir, will just love hook_user() (http://api.drupal.org/api/function/hook_user)

An example of how it will work for you in practice:

function yourmodule_user ($op, &$edit, &$account, $category = NULL) {
  switch ($op) {
    case 'form':
      return yourmodule_add_two_elements_to_the_form();
      break
    case 'update':
      // Intercept the user_save and modift the object before saving
    case 'after-update':
      // Modify the object after the save is complete
  }
}
anschauung
  • 3,697
  • 3
  • 24
  • 34
  • 1
    There's also a way to do this using template.php if you don't have a helper module to work this. Let me know if this is he case and I'll add an example to my response. – anschauung Sep 02 '10 at 23:01
  • No, this would be part of a custom module I am making to have a multistep registration form with CTools object cache. I will try this out. – Kevin Sep 02 '10 at 23:07
  • This answer + http://stackoverflow.com/questions/3343783/hook-user-inserting-extra-field-into-database-not-just-form/3344861#3344861 worked for me thanks – Kevin Sep 03 '10 at 16:20