Commit 225992c2 authored by Telenkov Ruslan's avatar Telenkov Ruslan

this is role task

parent 6558fd45
name: TestBf
description: Creates a page showing "Bootcamp".
name: Role Task
package: Custom
type: module
core_version_requirement: ^8.8 || ^9
<?php
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Session\AccountInterface;
use Drupal\node\NodeInterface;
/**
* Implements hook_node_access().
*/
function role_node_access(\Drupal\node\NodeInterface $node, $op, \Drupal\Core\Session\AccountInterface $account) {
$type = $node
->bundle();
if ($account->id() != '1') {
if ($type == 'editor' && $op == 'update') {
//Узнать uid в поле ноды
$uid_role = $node->get('field_role')->target_id;
// id текущего пользователя
$uid_now = $account->id();
if ($uid_now == $uid_role) {
return AccessResult::allowed();
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment