1

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.

Rancbar
  • 184
  • 12

1 Answers1

0

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:

  • 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()

See also

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

Hussard
  • 656
  • 7
  • 14
  • Thanks, I needed to get logged user id and that was my fault. It fixed by using `osc_logged_user_id()` function – Rancbar Apr 25 '16 at 09:57