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.