In a block there's a flag where users can ask for permission to edit the node. The admin gets a mail when the node is flagged. Admin can grant acces with node-acces to a particular user. This part is working.

However, when the user can edit the node, this block (or snippet; could use if else statement) should be hidden. I'm looking for (and can't find it) a snippet like

if user can edit 
    {'you can edit'} 
    {show flag}

How should I do the first part?

  • To clarify - do you want to hide the block when the user has node edit access? – longboardnode Oct 9 '15 at 2:44

Seems it can be done via this PoC

if (node_access('edit', $node, $user)) {
  {'you can edit'} 
else {
  {show flag}
  • what does PoC stand for? – No Sssweat Oct 9 '15 at 8:59
  • This code checks that concrete user have access to edit concrete node. And if yes, the executes some action. – Eugene Oct 9 '15 at 18:11

You should be able to get this to work using the Rules block visibility module, using a Rules Component that is pretty similar to what I described in my answer to "How to display a block if a user does NOT have a selected role?".

All you'd have to do is to adapt the Rules condition to make it check if "admin has granted acces with node-acces" (as in your question) to the current user.

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.