Skip to main content
added 32 characters in body
Source Link
Stefan
  • 1.3k
  • 8
  • 17

I'm having a strange behaviour while trying to use hook_node_access in Drupal 8 (Lightning to be more precise) and I can't figure out why is doing this. Let's suppose that I want to always allow people to edit a certain content type (I know I can setup role permissions to achieve this, but I'm just trying to understand why it's not working):

function mymodule_node_access($node, $op, $account) {
  $type = $node->bundle();
  if($type == 'service' && $op == 'update') {
      return AccessResult::allowed();
  }
}

I always get "access denied" while trying to edit a "service" node.

This is what I've tried to do in order to debug it:

  • in reports > status reports there are no node access permissions in use;
  • the current user does not have "bypass content access control" permission;
  • hook_module_implements_alter doesn't return any other module using hook_node_access.

Is there anything I'm missing?

I'm having a strange behaviour while trying to use hook_node_access in Drupal 8 (Lightning to be more precise) and I can't figure out why is doing this. Let's suppose that I want to always allow people to edit a certain content type (I know I can setup role permissions to achieve this, but I'm just trying to understand why it's not working):

function mymodule_node_access($node, $op, $account) {
  if($type == 'service' && $op == 'update') {
      return AccessResult::allowed();
  }
}

I always get "access denied" while trying to edit a "service" node.

This is what I've tried to do in order to debug it:

  • in reports > status reports there are no node access permissions in use;
  • the current user does not have "bypass content access control" permission;
  • hook_module_implements_alter doesn't return any other module using hook_node_access.

Is there anything I'm missing?

I'm having a strange behaviour while trying to use hook_node_access in Drupal 8 (Lightning to be more precise) and I can't figure out why is doing this. Let's suppose that I want to always allow people to edit a certain content type (I know I can setup role permissions to achieve this, but I'm just trying to understand why it's not working):

function mymodule_node_access($node, $op, $account) {
  $type = $node->bundle();
  if($type == 'service' && $op == 'update') {
      return AccessResult::allowed();
  }
}

I always get "access denied" while trying to edit a "service" node.

This is what I've tried to do in order to debug it:

  • in reports > status reports there are no node access permissions in use;
  • the current user does not have "bypass content access control" permission;
  • hook_module_implements_alter doesn't return any other module using hook_node_access.

Is there anything I'm missing?

deleted 11 characters in body
Source Link
user72672
user72672

I'm having a strange behaviour while trying to use hook_node_access in Drupal 8 (Lightning to be more precise) and I can't figure out why is doing this. Let's suppose that I want to always allow people to edit a certain content type (I know I can setup role permissions to achieve this, but I'm just trying to understand why it's not working):

function mymodule_node_access($node, $op, $account) {
  if($type == 'service' && $op == 'update') {
      return AccessResult::allowed();
  }
}

I always get "access denied" while trying to edit a "service" node.

This is what I've tried to do in order to debug it:

  • in reports > status reports there are no node access permissions in use;
  • the current user does not have "bypass content access control" permission;
  • hook_module_implements_alter doesn't return any other module using hook_node_access.

Is there anything I'm missing?

Thanks!

I'm having a strange behaviour while trying to use hook_node_access in Drupal 8 (Lightning to be more precise) and I can't figure out why is doing this. Let's suppose that I want to always allow people to edit a certain content type (I know I can setup role permissions to achieve this, but I'm just trying to understand why it's not working):

function mymodule_node_access($node, $op, $account) {
  if($type == 'service' && $op == 'update') {
      return AccessResult::allowed();
  }
}

I always get "access denied" while trying to edit a "service" node.

This is what I've tried to do in order to debug it:

  • in reports > status reports there are no node access permissions in use;
  • the current user does not have "bypass content access control" permission;
  • hook_module_implements_alter doesn't return any other module using hook_node_access.

Is there anything I'm missing?

Thanks!

I'm having a strange behaviour while trying to use hook_node_access in Drupal 8 (Lightning to be more precise) and I can't figure out why is doing this. Let's suppose that I want to always allow people to edit a certain content type (I know I can setup role permissions to achieve this, but I'm just trying to understand why it's not working):

function mymodule_node_access($node, $op, $account) {
  if($type == 'service' && $op == 'update') {
      return AccessResult::allowed();
  }
}

I always get "access denied" while trying to edit a "service" node.

This is what I've tried to do in order to debug it:

  • in reports > status reports there are no node access permissions in use;
  • the current user does not have "bypass content access control" permission;
  • hook_module_implements_alter doesn't return any other module using hook_node_access.

Is there anything I'm missing?

Source Link
Stefan
  • 1.3k
  • 8
  • 17

Why return AccessResult::allowed() ends up with "Access denied"?

I'm having a strange behaviour while trying to use hook_node_access in Drupal 8 (Lightning to be more precise) and I can't figure out why is doing this. Let's suppose that I want to always allow people to edit a certain content type (I know I can setup role permissions to achieve this, but I'm just trying to understand why it's not working):

function mymodule_node_access($node, $op, $account) {
  if($type == 'service' && $op == 'update') {
      return AccessResult::allowed();
  }
}

I always get "access denied" while trying to edit a "service" node.

This is what I've tried to do in order to debug it:

  • in reports > status reports there are no node access permissions in use;
  • the current user does not have "bypass content access control" permission;
  • hook_module_implements_alter doesn't return any other module using hook_node_access.

Is there anything I'm missing?

Thanks!