简体   繁体   English

提交表格前,强制匿名进行注册。 Drupal 7

[英]Force anonymous to register before submitting a form. Drupal 7

I want to force anonymous to register an account before submitting the form. 我想强制匿名在提交表格之前注册一个帐户。 So I have to allow permission for anonymous to access the form, Then I use hook_form_FORM_ID_alter to edit form. 因此,我必须允许匿名访问表单的权限,然后使用hook_form_FORM_ID_alter编辑表单。 Then I wanted to redirect submit button to another link if it is clicked by anonymous.(I still have no idea how to do it. It would be nice if anyone can tell me) Is this the right solution? 然后,如果要将匿名按钮单击,则我想将“提交”按钮重定向到另一个链接。(我仍然不知道该怎么做。如果有人可以告诉我,那将很好。)这是正确的解决方案吗?

For now, I have a pop-up a login form (Modal forms and Facebook OAuth). 现在,我弹出一个登录表单(模式表单和Facebook OAuth)。 In the form there is a register button. 表单中有一个注册按钮。 Then If user choose to register I want to keep the form that he have already input and show it after he confirm his email. 然后,如果用户选择注册,我想保留他已经输入的表格,并在确认电子邮件后显示它。

Thank you. 谢谢。

Off the top of my head, I would allow the form to be submitted either by an anonymous user or a registered one. 在我的头上,我允许匿名用户或已注册用户提交表单。

in my function MYMODULE_MYFORM_submit() I would check to see if the user is logged in. 在我的函数MYMODULE_MYFORM_submit()我将检查用户是否已登录。

If yes proceed as normal, if no, store the form, either in a temp SESSION variable or into a custom MySQL table and forward the user to login/register page (mysite.com/user) using drupal_goto('user') 如果是,则照常进行,否则,将表单存储在临时SESSION变量或自定义MySQL表中,然后使用drupal_goto('user')将用户转发到登录/注册页面(mysite.com/user drupal_goto('user')

once the user was registered you could then check for the existence of the form in the SESSION array or your MySQL table, and then carry on with the process as you would if the user had been logged in in the first place 注册用户后,您可以检查SESSION数组或MySQL表中是否存在该表单,然后继续进行该过程,就像用户首先登录时一样

Hope this makes sense or is of help 希望这有意义或有帮助

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

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