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.
If you're on a custom plugin page, you have to export the user manually.
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:
You can get it from the URL: use Params::getParam('userId')
and passing it as a GET parameter.
/index.php?page=custom&route=your_plugin_route&userId=12
Use the current logged user id: osc_logged_user_id()
This tutorial on how to develop Osclass plugins, might be useful.