<p>Assuming you want to do this from your transformer, then something like this should work:</p>

<pre><code>'transformer' =&gt; function($entry) {

    $isLoggedIn = craft()-&gt;userSession-&gt;isLoggedIn(); 

    if ($isLoggedIn) {
        // Do your custom logic.
    }

    return array(
        'title' =&gt; $entry-&gt;title,
        'url' =&gt; $entry-&gt;url,
        'description' =&gt; (string) $entry-&gt;description,
        'photos' =&gt; $photos
    );
},
</code></pre>

CC BY-SA 3.0
2017-06-06T18:36:17.337Z
huh - that's easy :)
Steven Grant
CC BY-SA 3.0
2017-06-05T21:02:13.717Z
2017-06-05T21:02:13.717Z
Brad Bell
<p>Working on a SPA with Vue and Craft and looking to check if a user is logged in to run some Vue conditional logic.</p>

<p>I imagine that will then enable me to check if the logged in user owns content to return as well?</p>

<plugin-elementapi>
Check for logged in user with the Element API plugin
# Check for logged in user with the Element API plugin

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

Working on a SPA with Vue and Craft and looking to check if a user is logged in to run some Vue conditional logic.

I imagine that will then enable me to check if the logged in user owns content to return as well?

**Tags:** plugin-elementapi


---

## 1 answers

### Answer by username_1 on 2017-06-05. Score: 2 | Accepted answer

Assuming you want to do this from your transformer, then something like this should work:
'transformer' => function($entry) {

    $isLoggedIn = craft()->userSession->isLoggedIn(); 

    if ($isLoggedIn) {
        // Do your custom logic.
    }

    return array(
        'title' => $entry->title,
        'url' => $entry->url,
        'description' => (string) $entry->description,
        'photos' => $photos
    );
},

> **Comments:**
> **username_0**: huh - that's easy :)  

---

