I know how to get the user who created a node after getting the node object.

$node = \Drupal::routeMatch()->getParameter('node');
$uid = $node->getOwnerId();
$user = \Drupal\user\Entity\User::load($uid);

Since an alternative to retrieving values of the node object is for example $node->nid->value, I tried to get the revision user ID this way.

$ruid = $node->revision_uid->value;

Unfortunately, this doesn't work, although I see with the Devel module that there is a value. So what is the equivalent in Drupal 8 to $node->revision_uid in Drupal 7?

1 Answer 1


$node->getOwnerID() returns the user ID for the user who created the node. If you need the user who created the revision, you need to use $node->getRevisionUser(), or $node->getRevisionUserId() for the user ID.

  • Great, thanks. So I suppose I will try the "set…" and "get…" found in node class member names on this page the next time: api.drupal.org/api/drupal/…
    – upunkt
    Mar 31, 2018 at 21:34
  • 1
    That page lists all the methods available for the Node class, including the ones defined in a parent class, or a trait used by the class. So, yes, that is the first place to look. It's not always that quick to find the right method to use, but it's a start.
    – apaderno
    Apr 1, 2018 at 1:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.