<p>Craft includes a function called <code>getVersionsByEntryId</code>, but its full functionality isn't exposed by default. You have to create a <a href="https://craftcms.com/docs/plugins/variables" rel="nofollow noreferrer">template variable</a> to get the most recent version.</p>

<p>If you only need the most recent version, you can add the following to your plugin's variables: </p>

<pre><code>/**
 * @param  EntryModel $entry The entry to search for.
 * @return EntryVersionModel
 */
public function getCurrentVersion($entry)
{
  $versions = craft()-&gt;entryRevisions-&gt;getVersionsByEntryId($entry-&gt;id, $entry-&gt;locale, 1, true);
  return reset($versions);
}
</code></pre>

<p>Then you can grab the author within your templates with the following:</p>

<pre><code>{{ craft.pluginName.getCurrentVersion(entry).creator }}
</code></pre>



CC BY-SA 3.0
2017-07-19T08:27:12.820Z
2018-02-21T21:29:48.410Z
2018-02-21T21:29:48.410Z
Jonathan
<p>You have to write a template variable that makes <code>getVersionsByEntryId()</code> available in Twig.</p>

<pre><code>public function getVersionsByEntryId($entryId, $localeId, $limit = 1, $includeCurrent = true)
{
    return craft()-&gt;entryRevisions-&gt;getVersionsByEntryId($entryId, $localeId, $limit, $includeCurrent);
}
</code></pre>

<p>You can now access an entry’s versions and get the current version’s creator like so.</p>

<pre><code>{% set versions = craft.businessLogic.getVersionsByEntryId(entry.id, entry.locale) %}
{% set author = versions|length ? versions[0].creator : entry.author %}

{{ author.fullName }}
</code></pre>

CC BY-SA 3.0
2017-04-05T13:36:30.867Z
2017-07-05T20:58:20.000Z
2017-07-05T20:58:20.000Z
carlcs
<p>How would I go about to get the author from the current version / revision of the entry I'm on? Im trying to get "last updated by" in frontend, but authorId on the entry seems to be the original author, not the last that edited it.</p>

<entries><author><entry-versions>
Get the author of current entry version?
# Get the author of current entry version?

(Asked by: username_0 on 2017-04-05)

How would I go about to get the author from the current version / revision of the entry I'm on? Im trying to get "last updated by" in frontend, but authorId on the entry seems to be the original author, not the last that edited it.

**Tags:** entries, author, entry-versions


---

## 2 answers

### Answer by username_1 on 2017-07-19. Score: 2 | Accepted answer

Craft includes a function called getVersionsByEntryId, but its full functionality isn't exposed by default. You have to create a template variable to get the most recent version.
If you only need the most recent version, you can add the following to your plugin's variables: 
/**
 * @param  EntryModel $entry The entry to search for.
 * @return EntryVersionModel
 */
public function getCurrentVersion($entry)
{
  $versions = craft()->entryRevisions->getVersionsByEntryId($entry->id, $entry->locale, 1, true);
  return reset($versions);
}

Then you can grab the author within your templates with the following:
{{ craft.pluginName.getCurrentVersion(entry).creator }}


---

### Answer by username_0 on 2017-04-05. Score: 4

You have to write a template variable that makes getVersionsByEntryId() available in Twig.
public function getVersionsByEntryId($entryId, $localeId, $limit = 1, $includeCurrent = true)
{
    return craft()->entryRevisions->getVersionsByEntryId($entryId, $localeId, $limit, $includeCurrent);
}

You can now access an entry’s versions and get the current version’s creator like so.
{% set versions = craft.businessLogic.getVersionsByEntryId(entry.id, entry.locale) %}
{% set author = versions|length ? versions[0].creator : entry.author %}

{{ author.fullName }}


---

