Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save algotrader-dotcom/1db77c90d44a928bb34e736ec80fd91e to your computer and use it in GitHub Desktop.
Save algotrader-dotcom/1db77c90d44a928bb34e736ec80fd91e 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