Hi there,

I have installed Webform and Webform Steps in my site; I need everyone can fill fields and see the form but only authenticated users can send it.

So I need the system to force the anonymous users to login or register before submiting the form. I installed Inline Registration but the problem is using Webform steps the login form is in the first page of the form and I need it to be at the end.

Anybody has any idea of how to do it? Custom module or something?

Thank you very much!!

Comments

jeepster created an issue. See original summary.

DanChadwick’s picture

What permissions or modules are used to configure webform such that it will display the form but not allow you to submit it? And what happens if you try to submit it?

I doubt that webform steps is an issue, but I'd try disabling it. As I understand the module, all it does is allow the progress bar to be clickable to navigate forward and backward through the webform pages.

jeepster’s picture

Hi Dan,

By now I need the Webform Steps working as it does. But I need also:

- or stop the submission process and force the anonymous users to login
- or hide the submit bottom and show a login or register form if they are anonymous

I found this hook:

function hook_webform_submission_presave($node, $submission) {
//test is user is anon
if (user_is_anonymous()) {
//tell user what is going on
drupal_set_message("Please register before submitting form");
//redirect to registration page, with path to send back to form when done
drupal_goto('user/register', array('query'=>drupal_get_destination()) );
}
}

but I can't make it work.

Thanks for writting!

DanChadwick’s picture

Status: Active » Fixed

That is not what that hook is for. I don't have a solution for you and we don't supply custom programming support in the issue queue. There just aren't sufficient resources. I'd suggest hiring a professional developer to achieve what you need.

jeepster’s picture

Hi Dan,

I'm a programmer and I need to solve it on my own. I asked here searching for ideas from people that may have needed the same feauture, as I helped others before; nothing else.

DanChadwick’s picture

If you want to modify the form, I think you'd start with hook_webform_client_form_NID_alter() to adjust the form for anonymous users. Continuing the submission after login may be tricky -- getting the form values back, etc. Sounds hard.

Maybe you can simply the problem by requiring login before starting the form. Either core or Login Toboggan (can't remember which) allows a redirect to the login page, then continuing to the destination token.

jeepster’s picture

Hi Dan,

thanks for asking again. It sounds hard, yes, but I use this feauture in Ubercart (includes in the form a login/register block) and works like a charm so I thought it wouldn't be so tricky.

I'll take a look to the hook you talked about.

Thanks!

DanChadwick’s picture

I would look to see how ubercart does it.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

sac0132’s picture

@jeepster, did you make any headway on this? would love to hear how you did it..

yaach’s picture

Looking for similar functionality - requiring login to access/view form. I was trying to make it work by just using Form Settings and only checking "Authenticated User" and it works but once I login I get "Access Denied".

Did anybody get this working with this or other approach.

jeepster’s picture

Maybe you can use Rules to redirect anonymous to login page (with Redirect to come back to form after log in).

In Form setting uncheck "Authenticated User".

yaach’s picture

@jeepster thanks for the suggestion. I didn't want to go for the route of installing a new module and work on Rules. I kept insisting on what webform has, and I was able to make it work. My problem of getting "Access Denied" was because the particular role I was using did not have "View Published content" permission.

jeepster’s picture

@yaach you can also use hook_form_alter() to hide submit button show login link if anonymous