Jump to content

Recommended Posts

Hi I installed this module today and I was testing it out and for some reason when you sign up for the newsletter it will tell you that the email is already signed up when its not ... but the thing is it displays that error but continues on with the inserting it into the database and sending a confirmation email ? Does anybody have this module and know how to get this to stop ? here is the bit of code that checks if the email has been used or not .

private function newsletterRegistration()
	{
		if (empty($_POST['email']) || !Validate::isEmail($_POST['email']))
			return $this->error = $this->l('Invalid email address');

		/* Unsubscription */
		else if ($_POST['action'] == '1')
		{
			$register_status = $this->isNewsletterRegistered($_POST['email']);
			if ($register_status < 1)
				return $this->error = $this->l('This email address is not registered.');
			else if ($register_status == self::GUEST_REGISTERED)
			{
				if (!Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'newsletter WHERE `email` = \''.pSQL($_POST['email']).'\' AND id_shop = '.$this->context->shop->id))
					return $this->error = $this->l('An error occurred while attempting to unsubscribe.');
				return $this->valid = $this->l('Unsubscription successful');
			}
			else if ($register_status == self::CUSTOMER_REGISTERED)
			{
				if (!Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'customer SET `newsletter` = 0 WHERE `email` = \''.pSQL($_POST['email']).'\' AND id_shop = '.$this->context->shop->id))
					return $this->error = $this->l('An error occurred while attempting to unsubscribe.');
				return $this->valid = $this->l('Unsubscription successful');
			}
		}
		/* Subscription */
		else if ($_POST['action'] == '0')
		{
			$register_status = $this->isNewsletterRegistered($_POST['email']);
			if ($register_status > 0)
				return $this->error = $this->l('This email address is already registered.');

			$email = pSQL($_POST['email']);
			if (!$this->isRegistered($register_status))
			{
				if (Configuration::get('NW_VERIFICATION_EMAIL'))
				{
					// create an unactive entry in the newsletter database
					if ($register_status == self::GUEST_NOT_REGISTERED)
						$this->registerGuest($email, false);

					if (!$token = $this->getToken($email, $register_status))
						return $this->error = $this->l('An error occurred during the subscription process.');

					$this->sendVerificationEmail($email, $token);

					return $this->valid = $this->l('A verification email has been sent. Please check your inbox.');
				}
				else
				{
					if ($this->register($email, $register_status))
						$this->valid = $this->l('You have successfully subscribed to this newsletter.');
					else
						return $this->error = $this->l('An error occurred during the subscription process.');

					if ($code = Configuration::get('NW_VOUCHER_CODE'))
						$this->sendVoucher($email, $code);

					if (Configuration::get('NW_CONFIRMATION_EMAIL'))
						$this->sendConfirmationEmail($email);
				}
			}
		}
	}

blocknewsletter.php

Link to comment
Share on other sites

×
×
  • Create New...