I am running a competition whereby users must fill in a webform to enter. However, I am also using Facebook connect, and want the web form page to display, with the body and all the rest except for the form itself, unless the user is logged in. What is the best way to:

  1. Allow access to the webform if anonymous?
  2. Not allow the user to submit the form if anonymous?
  3. Hide the form and show my custom Facebook login button if the user is not logged in?

Point 1 is basically using Webforms the default way. And point 3 I can probably do by just editing the template of the node. But I am not sure how I can override the validation of the form to stop the user from actually entering the competition if he is not logged in.

Any ideas on what the best way is to do this?

  • If you are already removing the form from the template... how would they submit it? Doesn't implementing 3 solve 2? – Chance G Mar 19 '15 at 21:47

I haven't done this, but it should work to do something like this: Once you've created the webform, on the settings for your webform, under "Submission access" you can choose to restrict "Roles that can submit this webform" to "authenticated user" and under "Advanced Settings" there's a checkbox to make the webform "Available as a block." Once you have the webform block, restrict the block to authenticated users only. Put the content that should be available to anonymous users on a new page and add your webform block to that page. The webform should then only show up on that page for authenticated users.

| improve this answer | |
  • That's not a bad idea and should work perfectly. Thanks! – coderama Mar 20 '15 at 5:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.