使用我的代码,用户每天可以编辑节点3次,但我希望用户每天可以编辑3次节点!
我尝试使用edit_limit模块,但是没有正常工作!
是否有使用check_node_access的方法?
感谢您的帮助!
function EDITLIMIT_check_node_access($op, $node){
global $user;
if (in_array('ROLE', $user->roles)) {
if ($user->uid == $node->uid) {
$currentdate=date("d-m-Y");
$prupdatedateformat=$node->changed;
$dateupdate=format_date($prupdatedateformat, 'custom', 'd-m-Y' );
if ($dateupdate === $currentdate) {
return FALSE;
} else {
return TRUE;
}
}
}
return node_access($op, $node);
}
您可以检查节点版本(如果启用)。您可以得到节点的$ vids数组,例如:
$vids = \Drupal::entityManager()->getStorage('node')->revisionIds($node);
然后像这样迭代槽:
foreach($vids as $vid){
$revision = \Drupal::entityTypeManager()->getStorage('node')->loadRevision($vid);
}
然后以某种方式读取修订日期。。
其他方法是在每次编辑节点时将成对的nid和编辑日期存储在某处,然后在尝试节点编辑时检查该数据。