简体   繁体   English

Drupal 7用户模块可针对不同角色进行自定义注册

[英]Drupal 7 user module customize for registration for different roles

I have a requirement of customizing user signup form in Drupal 7. i am not getting any relevant help from the internet . 我需要在Drupal 7中自定义用户注册表单。我没有从互联网获得任何相关帮助。 so i thought i should ask the expert here. 所以我想我应该问专家。

Requirement is i have two roles say "Student" and "Teacher". 要求是我有两个角色,分别是“学生”和“老师”。 I have to use default user module for their signup by setting their roles automatically. 我必须通过自动设置角色来使用默认用户模块进行注册。

Now there will be two links one for Student signup another for Teacher Sign up. 现在将有两个链接,一个用于学生注册,另一个用于教师注册。 When user click on Student SignUp i am hiding some fields of default user module which are suppose to fill by a teacher, so student will see only fields, which are specified. 当用户单击“学生注册”时,我正在隐藏默认用户模块的某些字段,这些字段应该由老师填写,因此学生将只能看到指定的字段。 Same for Teacher i am hiding fields which student suppose to fill. 老师也一样,我正在隐藏学生应该填写的字段。

So basically with the use of default user module i have to perform the sign up process. 因此,基本上,必须使用默认用户模块来执行注册过程。

Solution what i think could be possible : 解决方案,我认为是可能的:

I can set a variable in the link saying "studetnSignUp?status=student" and same for Teacher "studetnSignUp?status=teacher". 我可以在链接中设置变量“ studetnSignUp?status = student”,并为教师设置“ studetnSignUp?status = teacher”。 Now the problem is i can do this in php but do not have proficient way to the same in drupal. 现在的问题是我可以在php中做到这一点,但没有足够的方法在drupal中做到这一点。

If it can be possible with any other approach please let me know. 如果可以通过其他任何方式实现,请告诉我。 As it is really urgent for me. 对我来说真的很紧急。 Your support will be really appreciated. 非常感谢您的支持。 Thanks. 谢谢。

You can look into Profile2 in combination with Profile2 Registration Paths . 您可以结合使用Profile2注册路径来查看Profile2 It provides you with the ability to set a unique registration path for each Profile2 profile type. 它使您能够为每种Profile2配置文件类型设置唯一的注册路径。 Per profile type you can define different fields. 对于每种配置文件类型,您可以定义不同的字段。 And I think a helpful feature is that it can assign user roles by registration path. 而且我认为一个有用的功能是它可以按注册路径分配用户角色。

I would grab the passed parameter using menu and then call 我会使用菜单获取传递的参数,然后调用

hook_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'user_profile_form') {
  // do your processing here
  }
}

alter the layout of the form dependant of the user, and specify the users role in the form to, ie teacher or student 更改依赖于用户的表单的布局,并指定表单中用户的角色,即老师或学生

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM