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?

1 Answer 1


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
  • huh - that's easy :) Jun 6, 2017 at 18:36

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.