- This topic has 4 replies, 2 voices, and was last updated 13 years, 7 months ago by .
Viewing 5 posts - 1 through 5 (of 5 total)
Viewing 5 posts - 1 through 5 (of 5 total)
- You must be logged in to reply to this topic.
Support site for Tips and Tricks HQ premium products
by
Tips and Tricks HQ Support Portal › Forums › WP eStore Forum › Access $current_user from paypal.php
Hi – On my site I’m using the eStore plugin to allow users to purchase credits. I’d like to update the number of credits that a logged-in user owns by this simple bit of code, where $credits is the new value:
global $current_user;
get_currentuserinfo();
$user_id = $current_user->ID;
update_user_meta( $user_id, 'credits', $credits );
So that code works fine anywhere on my site, except when I try to use it within paypal.php. I can hardcode the value of $user_id and it will update the user’s credits field (so I know everything else is working correctly) but when I try to access $current_user->ID
, it just returns 0.
What am I doing wrong?
The IPN (payment notification) is a background HTTP POST. When paypal sends the IPN to eStore there is not active user present so current user variable does not return anything.
If you have integrated the PDT then you should try to do this credit update work there as the current user will be active in the browser and it will have the details of this user.
Thank you – can you just point me to the file I need to be working in for the PDT?
Please open the “wp_eStore1.php” file and search for the following line:
/*** PDT Stuff ***/
You should be able to read the block of code there and figure it out.
Okay, that’s done it. Thanks for your help.