-1

For my Drupal 8 website I have installed User Reference Node Access module to grant "Editing" permissions for co-editors. The module works fine for newly created content. But to make it work for already created nodes, you need to go to Edit page of the node and press the button "Save". Otherwise co-authors don't have an access to the nodes. I can not do it manually, as we have over 2000 nodes, it there a way to perform "Save" bulk operation, to make the module work ?

0

You can use drush php to do that.

Paste the following lines one by one and you should be fine.

$nids = \Drupal::entityQuery('node')->execute(); // Gets all node ids.
$nodes =  \Drupal\node\Entity\Node::loadMultiple($nids); // Loads all node entities.
foreach($nodes as $node) { $node->save(); } // Saves the nodes. 
  • You mean I need to use a command line to make it run? – user91143 Mar 6 at 13:23
  • There are ways to do it without using a command line, but yes, this solution uses the command line. Would that be a problem? – anpel Mar 6 at 13:26
  • 1
    Seriously, use Views Bulk Operations. – Kevin Mar 6 at 13:41
  • 1
    VBO will do everything you select, I have used it many times to process hundreds or thousands of updates. The point was, for most people coming to this site, they are not going to be pasting commands to a terminal, wasn't about speed. VBO will also batch out the process so you can do tons of actions without timing out or crippling the application. – Kevin Mar 6 at 14:47
  • 1
    There should be a toggle that says something like 'X selected, click here to select all'. – Kevin Mar 6 at 16:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy