We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Add function to Volt


i want to add a funtion to Volt, i am using vokuro. Here is the compiler

$compiler->addFunction('authUserById', function ($resolvedArgs) {return '!empty($this->session->auth-identity)';});

And that is the function to add:

public function authUserById($id)
    $user = Users::findFirstById($id);
    if ($user == false) {
        throw new Exception('The user does not exist');


    $this->session->set('auth-identity', array(
        'id' => $user->id,
        'name' => $user->name,
        'profile' => $user->profile->name

i only need the ID from the logged client, thank you in advance.




Find another way:

This in volt:

{{ loggedUser.id }}

This in indexAction:

    public function indexAction(){