mirror of
https://github.com/standardebooks/web.git
synced 2025-07-14 18:42:00 -04:00
Update user in database if they exist when processing a payment
This commit is contained in:
parent
de9e8161ce
commit
727e1af67d
2 changed files with 9 additions and 15 deletions
|
@ -25,16 +25,19 @@ class Payment extends PropertiesBase{
|
|||
|
||||
// If the User object isn't null, then check if we already have this user in our system
|
||||
if($this->User !== null && $this->User->Email !== null){
|
||||
$result = Db::Query('SELECT * from Users where Email = ?', [$this->User->Email], 'User');
|
||||
try{
|
||||
$user = User::GetByEmail($this->User->Email);
|
||||
|
||||
if(sizeof($result) == 0){
|
||||
// User exists, use their data
|
||||
$this->User = $user;
|
||||
|
||||
// Update their name in case we have their email (but not name) recorded from a newsletter subscription
|
||||
Db::Query('UPDATE Users set Name = ? where UserId = ?', [$this->User->Name, $this->User->UserId]);
|
||||
}
|
||||
catch(Exceptions\InvalidUserException $ex){
|
||||
// User doesn't exist, create it now
|
||||
$this->User->Create();
|
||||
}
|
||||
else{
|
||||
// User exists, use their data
|
||||
$this->User = $result[0];
|
||||
}
|
||||
|
||||
$this->UserId = $this->User->UserId;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue