Forums / Developer / How do i get the current user in my php script?
Douglas Hammond
Thursday 12 June 2003 9:53:16 am
This may be simp le but how do i get the current user in my php script?
get/set thier data members?
I am going to exatend the user class in the class manager and ad a field that my script needs to read or set.
Sven Ryen
Thursday 12 June 2003 10:43:34 am
don't know if this is to any help, but the user datatype is found here:
/kernel/classes/datatypes/ezuser/ezuser.php
Seems to me like you might want to extend the eZUser class.. Somebody please correct me if there's an easier way to accomplish this.
Bård Farstad
Thursday 12 June 2003 10:45:32 am
This is done with eZUser::currentUser(); that will return an eZUser object with the current logged in user.
Note that the user is a datatype, which is a part of a content object. To get access to the attributes you need to fetch the contentobject from the user object.
--bård
Documentation: http://ez.no/doc
Friday 13 June 2003 7:03:11 am
Thanks that's exactly what I was wondering. So I must get the content object that corresponds to the user. What datameber of ezUser corresponds to the contentId
is this right?
$user = &eZUser::currentUser();$userObject = &$user->attribute( "contentobject" );
Jo Henrik Endrerud
Friday 13 June 2003 7:26:17 am
After a quick check in the code it looks like you can do both. I think both will give the same result
Jo Henrik Endrerud | System Developer @ Seeds Consulting | http://www.seeds.no