You could use a programmatically solution using hook_node_access()
, in this example the field_YOURFIELD
is a checkbox.
function YOUR_MODULE_node_access(NodeInterface $node, $op, AccountInterface $account) {
$access = new AccessResultNeutral();
if ($node->hasField('field_YOURFIELD')) {
$field = $node->get('field_YOURFIELD')->getString();
if (empty($field) && $account->id() != $node->getOwnerId()) {
$access = new AccessResultForbidden();
}
}
$access->addCacheableDependency($field);
$access->addCacheableDependency($node);
return $access;
}