Anonymous users get an "Access denied" page when navigating to a simple webform-created form. I've disabled all other mmodules and still have the issue. I have checked access rights and only with "administer node" can they see and fill in the form. This happens on 2 different sites.

What am I missing here? I can't believe this hasn't been mentioned before ...

tyia

Comments

jacine’s picture

Status: Active » Closed (fixed)

Hi Tyia,

The webform module has its own permissions on the user access page. You do not want to give users the "administer nodes" permission because that also gives the permission to delete and edit nodes all nodes. Scroll down to the bottom of the user acesss page, and you will see the permissions for the webform module. All you need is "create webforms" permission for users to fill out the form.

thedawn’s picture

Status: Active » Closed (fixed)

Hi Jacine,

Thank you for the response. I've tried these settings - they are all enabled for anonymous users. When I said

only with "administer node" can they see and fill in the form

I meant to say that "administer nodes" is the only permission I've found which allows the form to be seen - no other permissions I've tried (including the Webform section) allow access to the form. Of course you're right, I don't want anonymous users to be able to edit/delete nodes.

As I mentioned I've also disabled all other modules, so it can't be an access conflict with another module.

thedawn’s picture

Status: Closed (fixed) » Active

Reopening ...

quicksketch’s picture

Status: Closed (fixed) » Active

Webform doesn't have any access control code to prevent users from viewing webforms. It's likely caused by an access control module like organic groups, taxonomy_access, or something similar.

thedawn’s picture

As I said I have disabled ALL modules and webform is the only one installed. I have never used organic groups, taxonomy_access etc.

This issue is all that's preventing me from releasing this site to the client. I have tried different versions of webform (running update,) moving the module, disabling, uninstalling, reinstalling and am pulling my hair out more than ever ...

Is there a mySQL table I can check or reset? Any other ideas where this might possibly be set? Anywhere I can look?

I am running Drupal 5.1.

Many thanks in advance

quicksketch’s picture

If you've ever installed any node access module, it make a change to the node_access table that will continue to plague you even if you've disabled (but not uninstalled) the module that changed it.

Check your node_access table, it should only have one row in it such as this:

mysql> SELECT * FROM node_access;
+-----+-----+-------+------------+--------------+--------------+
| nid | gid | realm | grant_view | grant_update | grant_delete |
+-----+-----+-------+------------+--------------+--------------+
|   0 |   0 | all   |          1 |            0 |            0 | 
+-----+-----+-------+------------+--------------+--------------+
1 row in set (0.00 sec)

If it doesn't contain this row (or contains other rows), then some node access module has mucked with your site. If you've never installed any modules for node access, then I'm not sure where the problem could be. However, I feel pretty confident that if you installed webform on a clean Drupal install, the problem wouldn't exist.

thedawn’s picture

node_access table is as above. It is not a clean Drupal install as the site has been in development for several months. However I don't tbelieve this should mean it is necessarily impossible to track down the origin of the problem.

I will start with a new install and add modules one by one ...

thedawn’s picture

Title: Access Denied for all custom forms » Access Denied for all custom forms - SOLVED

After many hours of searching ...

The status field for the webforms in the node table were set to '0'
Changing this to '1' allows anonymous use of the forms.

Why this was so I have no idea - perhaps if I get a chance I will investigate further later.

I will leave this issue active in case someone else has an explanation.

quicksketch’s picture

Title: Access Denied for all custom forms - SOLVED » Access Denied for all custom forms
Status: Active » Fixed

Thanks for the followup, what a strange thing to have occurring. I'll keep this in mind for others that have a similar problem. Thanks!

thedawn’s picture

Status: Fixed » Active

Actually, changing status to '1' also gives anonymous users Edit access to the form, so unfortunately this is not a solution.
I'll keep looking ...

EDIT: Correction - I still had User Access Permissions set to allow anonymous editing ...

So, the fix IS as mentioned in post #8 above:

In the node table, sort by node_type (Descending)
For any webform type, check that the status field is '1'

quicksketch’s picture

Status: Active » Fixed

Great :)

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

jef.koslowski’s picture

Version: 5.x-1.x-dev » 5.x-2.0
Category: support » bug
Status: Closed (fixed) » Active

Hi,

I was having the same issue here. Used the fix mentioned in post #8 and now its working (thanks for the tip).

Using Webform version 5.x-2.0 and Drupal 5.7.

jef.koslowski’s picture

Ok, I found the problem. When u create a webform, in the "publishing options", the field "published" doesnt come checked by default.

I dont know if this is a bug or not (im pretty new with Drupal).

quicksketch’s picture

I don't know why I didn't think of this initially, jef.koslowski is correct. Webform (intentionally) unpublishes all new webforms, because you have to add components to the node before it does any good. For this reason, new forms are *always* unpublished, until the "Publish" button is hit on the components form, or the Published checkbox is ticked on the normal node form.

spatialguru’s picture

#8 does not solve it for me - my node is published just fine. I am also unable to allow anonymous users to fill in a webform. Which options in access control are needed?

quicksketch’s picture

Status: Active » Fixed

spatialguru, if the node being published is not the problem, could you please open a new issue? The problem on this particular issue seems to be caused by the published flag. We'll need a more descriptive explanation of what you're experiencing.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

webengr’s picture

LOL

also on drupal 6,

duh

"When u create a webform, in the "publishing options", the field "published" doesnt come checked by default."

I only needed to set published for problem, I am glad this post was here to be googled, save me some foolish time.

gregstout’s picture

Version: 5.x-2.0 »

This just saved me so much time. Thanks!

webengr’s picture

LMAO

I made this mistake the last time I setup a website several months ago,
found this page and remembered "publishing options" after debugging... :)

senior moments are increasing!

OK Computer’s picture

Aha! This had me stumped for ages. Ticked the published box and it sorted it. Thanks very much!

xayberoptix’s picture

Thank you for clarifying this! It works!

uegonzalez’s picture

Version: » 5.x-1.10
Component: Miscellaneous » Code

I was having the same issue for custom webforms with multiple roles. When I created the webform, there is an option to specify which roles can "Submit" to the form, but there are never any options to specify who can "See" the forms. I believe the webforms try to use the node_access table, but there is no way to modify that table unless you are using a third party module like "Content Access".

The solution I came up with is to add a new "Access Control" permission called "view webforms" and gave those permissions to a specific role by going to the Access Control section in administration. You need to modify webform.module a little bit to get this to work. Namely webform_perm():

What I changed was:

/**
 * Implementation of hook_perm().
 */
function webform_perm() {
  return array('create webforms', 'edit own webforms', 'edit webforms', 'access webform results', 'clear webform results', 'access own webform submissions', 'edit own webform submissions', 'edit webform submissions', 'use PHP for additional processing');
}

to:

/**
 * Implementation of hook_perm().
 */
function webform_perm() {
  return array('view webforms','create webforms', 'edit own webforms', 'edit webforms', 'access webform results', 'clear webform results', 'access own webform submissions', 'edit own webform submissions', 'edit webform submissions', 'use PHP for additional processing');
}

All I added was 'view webforms' to the front so that you can use the GUI to select the appropriate permission. Now, you have to do something with that permission by going to webform_access():

I changed:

/**
 * Implementation of hook_access().
 */
function webform_access($op, $node) {
  global $user;

  switch ($op) {
    case 'create':
      return user_access('create webforms');
    case 'update':
    case 'delete':
      if (user_access('edit webforms') || (user_access('edit own webforms') && ($user->uid == $node->uid))) {
        return TRUE;
      }
  }
}

to:

/**
 * Implementation of hook_access().
 */
function webform_access($op, $node) {
  global $user;

  switch ($op) {
    case 'create':
      return user_access('create webforms');
    case 'update':
    case 'view':
        return user_access('view webforms');
    case 'delete':
      if (user_access('edit webforms') || (user_access('edit own webforms') && ($user->uid == $node->uid))) {
        return TRUE;
      }
  }
}

Here, I added the "view" case when accessing a webform. When you give the specific role the "view webforms" permission, then they will be able to access those custom webforms. Hope this helps.

thenarwhalkid’s picture

This totally fixed my problem with webform access! Thank you!

noderunner’s picture

Good news. I need the fix too.

Do I need to uninstall the module and then re-install once I add the code above?

Or do I just use update.php?

Will that fix work for 6.15?

noderunner’s picture

The above code is for 5.0 only right?

I tried it on 6.15, and the view was not created. I added the $account parameter without luck also.

A bit out of my depth here.

Must forge ahead, though.

illSleepWheniDie’s picture

Title: Access Denied for all custom forms » Access Denied for all custom forms. Fixed: Unpublished node

When I saw #8

After many hours of searching ...

The status field for the webforms in the node table were set to '0'
Changing this to '1' allows anonymous use of the forms.

I immediately checked "published" status .. and it worked .. duh! lol ..

Changing the title to help people a little bit more ..

Joar’s picture

mysql> SELECT * FROM node_access;
+-----+-----+-------+------------+--------------+--------------+
| nid | gid | realm | grant_view | grant_update | grant_delete |
+-----+-----+-------+------------+--------------+--------------+
|   0 |   0 | all   |          1 |            0 |            0 | 
+-----+-----+-------+------------+--------------+--------------+
1 row in set (0.00 sec)

http://drupal.org/node/226987#comment-747714
This did it for me, thank you!

enkara’s picture

The same here, it was unpublished. I think it's not a good idea to unpusblish it by default, because the normal thing is to have it published. I think people is smart enough to keep the form url in secret until they are done making the changes.