I am going to be using Drupal in an upcoming project. I will need to extend the details that users enter in at login, such as regional information and some other custom stuff. I was wondering if anyone has any good recomendations on how to produce a module that does not make me an island in the Drupal world. I don't want to build this module, and then be stuck in no mans land(ala Mambo). I have a lot of registration info to collect, so I will need to stretch the registration process over three seperate form submittals... anyone have a clever idea for how to do that...?

Right now, I am taking the original user module and modifying it to suit my needs. Its really obvious how to add and remove registration details and forms in there, but it would be even nicer if you could do it dynamically from an administration page...

So, any thoughts?

Comments

Dublin Drupaller’s picture

Hi Alan,

Before you start creating a module, I recommend you check out the out-of-the-box profile.module with Drupal.

  1. go to ADMINISTER -> MODULES
  2. enable the profile.module
  3. save configuration
  4. go to ADMINISTER -> SETTINGS -> PROFILES
  5. under ADD NEW FIELD click on SINGLE-LINE TEXTFIELD
  6. give it a name, like COUNTRY
  7. At the bottom of the form, you can specify whether that field should appear on the regisration page or not, whether it is required etc.

hope that helps.

Dub

Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate

stmh’s picture

I solved this without the profile.module because I needed a three-step-registration-process (and I did not like the standard form-layout of drupal).

My registration-process is divided into the following steps:
1. user registrates with the built-in form
2. the password is sent to the new user
3. the user logs in
4. my custom module checks in the hook_menu if the user has finished the registration process, if not, it jumps to my custom registration-page via drupal_goto, where the user can finish his registration.
5. after successful registration, a flag is stored inside a custom databasetable

so no weird hacking inside the user.module necessary.

This is why I like drupal so much, you can do whatever you want, even without hacking the core-files :)

HTH ...

dgeilhufe@yahoo.com’s picture

CiviCRM is a robust constitutent relationship management system. It have been tigtly integrated with Drupal.

CiviCRM provides a replacement to the built in drupal profile functionality, with data saved to the CRM record. CiviCRM profiles can be stand alone HTML forms, which would handle your multi-step use case.

Docs:
http://objectledge.org/confluence/display/CRM/Configure+CiviCRM+Profile

David Geilhufe
Social Source Foundation
Try CiviCRM http://www.openngo.org/

alan.mclean’s picture

This is exactly what I was thinking. And the profile module where you can add fields was another idea. I need to be able to track regional info with a custom module... so having it in seperate fields or tables is especially important. Would you be willing to share your code?

--Alan

dgeilhufe@yahoo.com’s picture

You can download CiviCRM from www.openngo.org (right sidebar).
Or download CivicSpace if you prefer an automated installer. Link to civicspace download at www.openngo.org, right sidebar.

David Geilhufe
Social Source Foundation
Try CiviCRM http://www.openngo.org/

alan.mclean’s picture

Sorry, I should have quoted you directly, I meant YOUR method seemed exactly what I was thinking of doing. Are you willing to share some of your code on that? I have never developed a drupal module before, so I would appreciate a good example of how you hooked into the core like that...

dgeilhufe@yahoo.com’s picture

Some basic overview docs:
http://objectledge.org/confluence/display/CRM/CiviCRM+and+Drupal
(more on the wiki)

Review the .module file which contains all the drupal specific code:
http://svn.civicrm.org/trunk/modules/civicrm.module

David Geilhufe
Social Source Foundation
Try CiviCRM http://www.openngo.org/

alan.mclean’s picture

Thank you for your comments regarding the CRM, but I am not interested in such a comprehensive solution.

Here is what I want to do:(similiar to stephanmaximili)

1. User requests registration

2. If they are user type A, flag as that user. If type B, flag appropiate (User name,password,email)

3. Depending on user type, reveal appropiate reg info. Registration should be split into 3 seperate page requests, as there is a lot of info, and it is all categorized.

4. Process all the data. If the user is type A, setup as normal contributer. If the user is type B, setup as a subsite owner.

....ideas???

stmh’s picture

Sorry, I missed your reply...

I can't share the code, because it would be too complicated to understand :)

Anyway, here are the main-concepts: I check in the hook_menu if somebody is logged in, and if so, if he has completed my registration-page. If not the user is forwarded to a special page, where he can start registering.

We need a special permission, so we can fine tune the registration

function custom_registration_perm() {
  // we use a special permission, so we can administer certail user-roles to do the registration
  return array('need registration');
} 

we check if the user has completed the registration in the hook_menu

function custom_registration_menu($may_cache) {
  global $user;
  // so, if someone logged in, we check, if he has already filled out the registration form
  
  if (($user->uid) && (arg(1) != 'logout') && ((arg(1) != 'login') || (arg(1) != 'complete_registration'))) {
    _custom_registration_check_user_registration($user);
  }
  
  // here I register the callback for my registration-page:
  if ($may_cache) {

    $items[] = array(
      'path' => 'user/complete_registration', 
      'title' => t('Please complete your personal info'),
       'callback' => 'custom_registration_page', 
      'access' => user_access('need registration'),
      'type' => MENU_CALLBACK); 
      
    // more stuff
  }
}

This function checks, if the user is an an admin or has no rights to complete registration

function _custom_registration_check_user_registration(&$user) {
  if (($user->uid == 1) || (user_access('need registration') == false)) {
    // it is the admin, or user does not need to registrate
    return;
  }
  else {
    //query the database if the user has completed the registration
    if (custom_registration_has_user_completed_registration())
      return;
    else // here we jump to our custom-registration-page
      drupal_goto('user/complete_registration');
  }
}

Thsi function queries a table and where additional infos about the registrationprocess is stored

function custom_registration_has_user_completed_registration() {
  // queries a custom table if user has competed registration... 
  global $user;
  $result = db_query_range('SELECT n.completed FROM {my_users} n WHERE n.uptr = %d', $user->uid, 0, 1); 
  if (($result) && ($node = db_fetch_object($result))) {
    return $node->completed;
  }
  
  return false;

}

This function is called, when the user visits user/complete_registration:
It should render your forms and validates them... (This is hard stuff, but doable :))

function custom_registration_page() {
  // render, validates the forms, etc
  
  print theme('page', 'todo');
}

anyway it is a little bit messy, but perhaps you'll get idea. You should also check the documentation and handbooks for developing modules on drupal.org.

HTH,
Stephan

kushi_iiim’s picture

Can we use 2 different registration forms having different fields can you have me in this?