4

I have a content type Poll with an unpublished option. When a user creates a poll the poll remains unpublished for 1 hour and after that it becomes published (done with rules).

What i want to achieve is: Give the Poll author the permission to edit his poll node only while it is unpublished. When it gets published this permission will expire.

How can i work this out?

  • i guess this is a tough one. – Billy Feb 22 '13 at 10:46
3

hook_node_access() to the rescue! You need to create a new module to do this. In the new module's .module file you'll need to put this:

function YOUR_MODULE_node_access($node, $op, $account) {
  // Deny updating the content if it's a published poll
  if ($node->type == 'poll' && $node->status && $op == 'update') {
    drupal_set_message('This poll has been published, you may not make changes to it.','error');
    return NODE_ACCESS_DENY;
  }
}
  • Thank you very much for your answer. You saved me from a lot of research. – Billy Feb 27 '13 at 12:53

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.