Add default wishlist after registering

This commit is contained in:
Jay Trees 2022-03-04 10:53:25 +01:00
parent 351665dbe3
commit f186d062ac

View file

@ -55,6 +55,8 @@ if (isset($_POST['email'], $_POST['password']) && !empty($_POST['planet'])) {
} }
if ($isHuman) { if ($isHuman) {
$userRegistered = false;
if (isset($_GET['password-reset'], $_GET['token'])) { if (isset($_GET['password-reset'], $_GET['token'])) {
/** /**
* Password reset * Password reset
@ -100,6 +102,7 @@ if (isset($_POST['email'], $_POST['password']) && !empty($_POST['planet'])) {
100 100
) )
;'); ;');
$userRegistered = true;
} else { } else {
if (in_array($_POST['email'], $emails)) { if (in_array($_POST['email'], $emails)) {
$page->messages[] = Page::error( $page->messages[] = Page::error(
@ -116,11 +119,33 @@ if (isset($_POST['email'], $_POST['password']) && !empty($_POST['planet'])) {
"' . sha1($_POST['password']) . '" "' . sha1($_POST['password']) . '"
) )
;'); ;');
$userRegistered = true;
$page->messages[] = Page::success('Your account was successfully created.', 'Success'); $page->messages[] = Page::success('Your account was successfully created.', 'Success');
} }
} }
} }
/**
* Insert default wishlist
*/
if ($userRegistered) {
$userID = $database->lastInsertID();
$wishlistName = 'My hopes and dreams';
$database
->query('INSERT INTO `wishlists`
(
`user`,
`name`,
`hash`
) VALUES (
' . $userID . ',
"' . $wishlistName . '",
"' . sha1(time() . $userID . $wishlistName) . '"
)
;');
}
} else { } else {
$page->messages[] = Page::error( $page->messages[] = Page::error(
'<strong>' . $planetName . '</strong> '<strong>' . $planetName . '</strong>