I have a module which defines a content type, based on node_example.module. I want anonymous users to be able to create nodes of this type, protected by CAPTCHA. When I set "create story content" for anonymous users, /node/add works correctly, but when I set the permission "create school" (see code below) for anonymous, it seems like Drupal ignores me!

Drupal 6.1.4
CAPTCHA 6.x-2.0-rc3

/**
 * Implements hook_perm().
 */
function school_perm() {
  return array('create school', 'edit own school', 'delete own school', 'edit any school', 'delete any school');
}

/**
 * Implements hook_node_access().
 */
function school_access($op, $node, $account) {
  if ($node->type == 'school') {
    switch ($op) {
      case 'create':
        return user_access('create school', $account);
        break;
      case 'update':
        return (user_access('edit any school', $account) || (user_access('edit own school', $account) && ($account->uid == $node->uid)));
        break;
      case 'delete':
        return (user_access('delete any school', $account) || (user_access('delete own school', $account) && ($account->uid == $node->uid)));
        break;
    }
  }
}

Comments

clemens.tolboom’s picture

Status: Active » Closed (fixed)

[ Powered by #1115636: Issue Macros and Templates - _default]

As this is an old support request I assume this is not relevant anymore for you or the community.
It would help the developers when you close an issue the moment it is resolved by yourself.

Please document your resolution as a last comment so others can make use of it too.

Feel free to re-open this issue if you want to provide further information. Thanks.