2012-01-21 11 views
1

学生と教師の2種類の登録方法はどのように実装しますか? 私は教師用と学生用の2種類の登録が必要です。両方とも登録が異なり、どちらも役割が異なります。 Drupalで可能ですか?学生登録が必要です。管理者の承認はありませんが、教師登録の場合は管理者の承認が必要です。どうすればDrupal 6でこれを達成できますか?Drupalでの複数レベルの登録

答えて

1

私が知っている限り、drupalは複数のタイプの登録フォームを持つためのメカニズムを提供していません。しかし、あなたは簡単に自分の登録フォームを作成することができます。本当に必要なのは、新しいユーザーを作成するuser_save関数です。役割の種類にもう一つの選択ボックスフィールドを追加form_submitフック

function add_student_form_submit($form, &$form_state) { 

    $fields = array(); 
    $fields['is_new'] = true; 
    $fields['name'] = $form_state['values']['user_name']; 
    $fields['pass'] = $form_state['values']['pass']; 
    $fields['status'] = 1; 

    // $user = user_save(drupal_anonymous_user(), $fields); //This works in D7 
    $user = user_save('', $fields); //pretty sure this is what works in D6 
} 

あなたは、各フォームカスタムユーザー登録フォームで

2

のために好きなカスタムロジックを作成することができ、これを使用するの一環として、以下のサンプルコードを参照してください。 (学生、教師)。次に、以下に示すようにサブミットフックチェックを行います。

function add_student_form_submit($form, &$form_state) { 

$fields = array(); 
$fields['is_new'] = true; 
$fields['name'] = $form_state['values']['user_name']; 
$fields['pass'] = $form_state['values']['pass']; 

$role_type = $form_state['values']['role_type']; 

//Add the user to the corresponding role 
$fields['roles'] = array($role_type) 

//here you can achieve the thing which you want.If the role is a teacher then set 
//status = 0, else status = 1 
if($role_type == 'student') 
    $fields['status'] = 1; 
else 
    $fields['status'] = 0; // $user = user_save(drupal_anonymous_user(), $fields); //This works in D7 

$user = user_save('', $fields); //pretty sure this is what works in D6 } 

ユーザーは、あなたがhttp://localhost/domain_name/admin/user/userに行くべき教師である場合。ここでは、非アクティブユーザーをフィルタリングしてアクティブにすることができます。

2

あなたは、以下のモジュールを使用してマルチレベル登録を作成できます。

http://drupal.org/project/content_profile http://drupal.org/project/autoassignrole

上記のモジュールは、サイトでのマルチレベルの登録フォームを作成するのに役立ちます。コンテンツのプロファイルから、フォームを作成して、自動割り当てロールを学生に与えることもできます。

関連する問題