How do i get the current user in my php script?

Author Message

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

Douglas Hammond

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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 31 2025 00:23:41
Script start
Timing: Jan 31 2025 00:23:41
Module start 'layout'
Timing: Jan 31 2025 00:23:41
Module start 'content'
Timing: Jan 31 2025 00:23:41
Module end 'content'
Timing: Jan 31 2025 00:23:41
Script end

Main resources:

Total runtime0.0214 sec
Peak memory usage4,096.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0046 588.2656151.2266
Module start 'layout' 0.00460.0046 739.4922220.7188
Module start 'content' 0.00930.0108 960.21091,001.8359
Module end 'content' 0.02010.0013 1,962.046933.9922
Script end 0.0213  1,996.0391 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002511.8256140.0002
Check MTime0.00114.9704140.0001
Mysql Total
Database connection0.00062.858310.0006
Mysqli_queries0.002712.559430.0009
Looping result0.00000.102610.0000
Template Total0.00104.410.0010
Template load0.00073.429210.0007
Template processing0.00021.001410.0002
Override
Cache load0.00052.455710.0005
General
dbfile0.00020.921280.0000
String conversion0.00000.056940.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs