I am trying to grab the uid of the currently logged on user. AFAIK, I should be able to use $user->uid which should return the uid. Calling that returns nothing. Or Null, I'm not sure, but I know its not returning the uid of the current user. Trying to do a print_r($user) also returns nothing, so it seems like the $user global is empty. If I explicitly declare Global $user; in the php, I then get the user login block which is normally not there. (I'm using NTLM auth via the webserver_auth module) It also then spits out errors in the log as Anon instead of my user. If I remove the global declaration it returns to normal. However I still get no valid data for uid. Am I doing something blatently wrong here? Or does using the webserver_auth somehow change how I have to grab the uid for the current user. Any help would be appreciated. Thanks
By hcst on
Comments
Did you ever get a response
This is happening to me in an ecommerce module, and I need to know how to get the user context back since the user is still logged in.
tagging along
hey SomebodySysop,
are you using the paypal component of the ecommerce module?
I'm trying to track down a bug with the ecommerce/pay-per-node modules working together, and this seems to be the issue.
Anyone have thoughts on this???
-doc
My problem was with IPN
I created a ticket.module from the tangible.module following these instructions: http://drupal.org/node/84421
I added code to the case 'on payment completion' section of the ticket_productapi(&$node, $op, $a3 = null, $a4 = null) function.
Problem is that it is the paypal/ipn that calls that function when paypal sends back the payment details. Since it is paypal executing the program and NOT the user, global $user doesn't bring back anything. Therefore, we don't know who the user is that has just completed this transaction.
Since paypal sends a variable when it makes it's call to the ipn, I modified the 'on payment completion' code to read this variable and get data which would allow me to determine who the user is:
In my case, all I wanted to do was get the payer's e-mail address. This is NOT necessarily the Drupal user address since the user could have used another e-mail address when he fills out the paypal info, but it will do for me. I could have gotten the Drupal user e-mail address by simply using the item_number from the ipn results and searching the transaction table for the user id.
Not sure what your problem is, but hope this helps.
ah... pretty simple fix,
ah... pretty simple fix, thanks.
I just did:
and I'm in business...
thanks, I spent too long on that one :)
Strange and simple fix
I had the same problem. I tried to use the uid for the option at the blocks-menu of drupal were you can decide wheter a block should be shown on an site or not.
It should work if you add the following line before "global $user...":
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
After the refresh of your browser-window everything should work as aspected.
Curiously you should now be able to delete the added line without losing the possibility of grabbing the uid.
Hope this resolves your problem.