helperuseridosclasscustom-pages

osclass current user id function returns 0 as result in plugin custom page


I want to list the current user items in my custom page and add some custom operations in that custom page, But i can't get current user id from hUsers helper using this function:

osc_user_id();

it returns 0 as the result. what can i do to achieve this?

thanks in advance.


Solution

  • If you're on a custom plugin page, you have to export the user manually.

    How to export the user on custom page in Osclass

    View::newInstance()->_exportVariableToView("user", User::newInstance()->findByPrimaryKey($userId));
    

    If you're in a controller,

    $this->_exportVariableToView("user", User::newInstance()->findByPrimaryKey($userId));
    

    Then, $userId will depend on which user you refer to:

    See also

    This tutorial on how to develop Osclass plugins, might be useful.