Can't view current user info
Permalink 1 user found helpful
This doesn't seem to say that you have to load a library or anything to get access to the current users info, but I'm not having any luck.
I have created a package which is made up of a single library - it's a 3rd party voting script that I want to use. I have it working on a single page, with the package being loaded when the page starts:
class QuestionsController extends Controller {
public function on_start() {
...
Loader::package($voting);
...
}
}
The package controller loads the voting script:
class VotingPackage extends Package {
...
public function on_start() {
Loader::library('thumbsup/init', 'voting');
}
}
Everything loads and appears to work great. However, when my voting script has a call to check to see if the person voting is logged in:
$u = new User();
$user_id = (int) $u->getUserID();
Then everything falls apart and I get the error:
Fatal error: Class 'User' not found
Can anyone tell me what I need to do so that a class a package library can access the User info?
Thanks
I have created a package which is made up of a single library - it's a 3rd party voting script that I want to use. I have it working on a single page, with the package being loaded when the page starts:
class QuestionsController extends Controller {
public function on_start() {
...
Loader::package($voting);
...
}
}
The package controller loads the voting script:
class VotingPackage extends Package {
...
public function on_start() {
Loader::library('thumbsup/init', 'voting');
}
}
Everything loads and appears to work great. However, when my voting script has a call to check to see if the person voting is logged in:
$u = new User();
$user_id = (int) $u->getUserID();
Then everything falls apart and I get the error:
Fatal error: Class 'User' not found
Can anyone tell me what I need to do so that a class a package library can access the User info?
Thanks
It's possible that Concrete5 hasn't loaded up user info yet (because you're in the on_start event). You might need to manually load the user model before calling $u = new User():
Thanks Jordan Lev,
I don't know about kevinwwilson about this discussion posted in 11/18/11...
but today your reply useful to me...
Thanks a lot...
I don't know about kevinwwilson about this discussion posted in 11/18/11...
but today your reply useful to me...
Thanks a lot...