2

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?

2

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
    );
},

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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