0

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. 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). 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.

4

1 回答 1

1

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.

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')

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

Hope this makes sense or is of help

于 2013-07-02T11:13:54.627 回答