Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@batigolix
Created May 25, 2016 20:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save batigolix/be2feac4b346ea009733ec37ed6c5239 to your computer and use it in GitHub Desktop.
Save batigolix/be2feac4b346ea009733ec37ed6c5239 to your computer and use it in GitHub Desktop.
Update drupal 8 node and save
use Drupal\node\Entity\Node;
function _svv_tools_set_author() {
$user = user_load_by_name('test');
$query = \Drupal::entityQuery('node');
$nids = $query->execute();
dd($nids);
foreach ($nids as $nid) {
$node = Node::load($nid);
$node->uid->value = $user->id();
$node->save();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment