Answers.Body: <p>There is no &quot;direct&quot; attribute (i.e. similar to <code>entry.author</code>) for getting the user who last edited an entry. This is because entries don't actually keep track of their &quot;history&quot;; this is the responsibility of the <em>revision</em> system.</p>
  <p>Essentially, what you're looking for is the <em>creator of the current (i.e. last/newest) entry revision</em>.</p>
  <p>Unfortunately, Craft doesn't make it very easy to get to that revision creator user - but it can be achieved using a custom database query.</p>
  <p>There are a few different ways this query can be approached, but perhaps one of the most effective ones is by creating a <a href="https://craftcms.com/docs/4.x/users.html#querying-users" rel="nofollow noreferrer">UserQuery</a> (since we're looking for a user!), and using an <a href="https://craftcms.com/docs/4.x/element-queries.html#joins" rel="nofollow noreferrer">inner join</a> on the <code>revisions</code> database table to conditionally query for the same user that is referenced in the current revision's <code>creatorId</code> database column:</p>
  <pre><code>{% set revisionCreatorUser = craft.users
      .innerJoin('{{%revisions}} AS revisions', &quot;revisions.creatorId = elements.id AND revisions.id = #{entry.currentRevision.revisionId}&quot;)
      .one()
  %}
  </code></pre>
  <p>It's probably a good idea to code this a bit more defensively though, and to make the code fall back to the <code>entry.author</code> in cases where there is no current revision, or the revision creator can't be found:</p>
  <pre><code>{% set currentRevisionId = entry.currentRevision.revisionId|default %}
  {% if currentRevisionId %}
      {# Query for the current revision's creator #}
      {% set revisionCreatorUser = craft.users
          .innerJoin('{{%revisions}} AS revisions', &quot;revisions.creatorId = elements.id AND revisions.id = #{currentRevisionId}&quot;)
          .one()
      %}
  {% endif %}
  
  {# Set the lastEditedByUser variable to the revision creator if it exists, or the entry author if not #}
  {% set lastEditedByUser = revisionCreatorUser ?? entry.author %}
  
  &lt;p&gt;Entry last edited by: {{ lastEditedByUser.username }}&lt;/p&gt;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-06-05T23:03:44.493Z
Answers.Text: Thanks @Mats, much appreciated.
Answers.UserDisplayName: 4midori
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-16T21:14:50.973Z
Answers.LastActivityDate: 2023-05-16T21:22:31.383Z
Answers.LastEditDate: 2023-05-16T21:22:31.383Z
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Body: <p>How do I get the last editor of an entry on the front end? There are answers to this question here, but they relate to plug-ins. I'd like to access the information directly.</p>
  <p><strong>{{ entry.author.username }}</strong> returns the original author, but I need the person who most recently edited the entry.</p>
  
Tags: <entry>
Title: Getting an entry's last editor
ThreadText: # Getting an entry's last editor
  
  (Asked by: username_0 on 2023-05-16)
  
  How do I get the last editor of an entry on the front end? There are answers to this question here, but they relate to plug-ins. I'd like to access the information directly.
  
  **{{ entry.author.username }}** returns the original author, but I need the person who most recently edited the entry.
  
  **Tags:** entry
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-05-16. Score: 3 | Accepted answer
  
  There is no "direct" attribute (i.e. similar to `entry.author`) for getting the user who last edited an entry. This is because entries don't actually keep track of their "history"; this is the responsibility of the *revision* system.
  
  Essentially, what you're looking for is the *creator of the current (i.e. last/newest) entry revision*.
  
  Unfortunately, Craft doesn't make it very easy to get to that revision creator user - but it can be achieved using a custom database query.
  
  There are a few different ways this query can be approached, but perhaps one of the most effective ones is by creating a [UserQuery](https://craftcms.com/docs/4.x/users.html#querying-users) (since we're looking for a user!), and using an [inner join](https://craftcms.com/docs/4.x/element-queries.html#joins) on the `revisions` database table to conditionally query for the same user that is referenced in the current revision's `creatorId` database column:
  
  ```
  {% set revisionCreatorUser = craft.users
      .innerJoin('{{%revisions}} AS revisions', "revisions.creatorId = elements.id AND revisions.id = #{entry.currentRevision.revisionId}")
      .one()
  %}
  
  ```
  
  It's probably a good idea to code this a bit more defensively though, and to make the code fall back to the `entry.author` in cases where there is no current revision, or the revision creator can't be found:
  
  ```
  {% set currentRevisionId = entry.currentRevision.revisionId|default %}
  {% if currentRevisionId %}
      {# Query for the current revision's creator #}
      {% set revisionCreatorUser = craft.users
          .innerJoin('{{%revisions}} AS revisions', "revisions.creatorId = elements.id AND revisions.id = #{currentRevisionId}")
          .one()
      %}
  {% endif %}
  
  {# Set the lastEditedByUser variable to the revision creator if it exists, or the entry author if not #}
  {% set lastEditedByUser = revisionCreatorUser ?? entry.author %}
  
  <p>Entry last edited by: {{ lastEditedByUser.username }}</p>
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks @username_1, much appreciated.  
  
  ---
  
  