eZUser::currentUser() returns anonymous

Author Message

Stéphane Le Merre

Saturday 17 July 2010 12:02:37 pm

Hello,

I'm currently working on an extension for paying registration into eZPublish. To build this, i'm using 2 workflow/triggers :

  • checkout > before to pay with a bank extension i made,
  • checkout > after to put user into the premium user group for a limited time.

I'm having a problem in checkout > after : using eZUser::currentUser() always returns anonymous user.

I tryed to watch the $process parameter of the execute() method my workflow : user id passed in the object is 10 too (anonymous user); so i cannot find a way to get my current user.

If i disable the payment workflow/trigger, i can get my user normally using eZUser::currentUser().

Am i doing something wrong ?

Regards,
Stéphane.

PS : I'm using eZPublish 4.3

http://www.ligams.com

Stéphane Le Merre

Saturday 17 July 2010 4:05:58 pm

I found out how to solve this, the checkout->after workflow is call by the bank script with no session in it, that's why eZUser::currentUser() returns anonymous. Quiet stupid question but i'm tired :)

Maybe solution can help, so i get the user from the order_id :

function execute( $process, $event )
 {
     $bResult = false;
     $s = new PremiumSubscription();
        
     $processParams  = $process->attribute( 'parameter_list' );
     $orderID        = $processParams['order_id'];
     $order          = eZOrder::fetch( $orderID );
     $currentUser    = $order->user();
     $userId         = $currentUser->id();

     //...
}

Regards,
Stéphane.

http://www.ligams.com

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 18 2025 02:04:43
Script start
Timing: Jan 18 2025 02:04:43
Module start 'layout'
Timing: Jan 18 2025 02:04:43
Module start 'content'
Timing: Jan 18 2025 02:04:44
Module end 'content'
Timing: Jan 18 2025 02:04:44
Script end

Main resources:

Total runtime0.7446 sec
Peak memory usage4,096.0000 KB
Database Queries52

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0047 595.1172152.6250
Module start 'layout' 0.00470.0031 747.742239.4453
Module start 'content' 0.00780.7352 787.1875498.2813
Module end 'content' 0.74300.0016 1,285.46888.1563
Script end 0.7446  1,293.6250 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.4572160.0002
Check MTime0.00140.1865160.0001
Mysql Total
Database connection0.00070.089410.0007
Mysqli_queries0.692793.0337520.0133
Looping result0.00040.0563500.0000
Template Total0.711995.620.3560
Template load0.00220.289820.0011
Template processing0.709795.315820.3549
Template load and register function0.00010.017210.0001
states
state_id_array0.00070.091910.0007
state_identifier_array0.00140.194320.0007
Override
Cache load0.00180.2456290.0001
Sytem overhead
Fetch class attribute can translate value0.00050.067410.0005
Fetch class attribute name0.00160.210030.0005
XML
Image XML parsing0.00180.237510.0018
class_abstraction
Instantiating content class attribute0.00000.001440.0000
General
dbfile0.00190.2615160.0001
String conversion0.00000.001240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/strong.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/strong.tplEdit templateOverride template
2content/datatype/view/ezxmltags/li.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/li.tplEdit templateOverride template
1content/datatype/view/ezxmltags/ul.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/ul.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 23
 Number of unique templates used: 10

Time used to render debug report: 0.0002 secs