A user with such an e-mail is already registered...

Write about issues that you have found.

Moderators: Koduc, Xpycm

Forum rules
Pay attention! Forum is not a means for guaranteed support of clients and users. An answer as well as a quick answer is not supposed on the forum. We post messages as soon as possible.

The message limit on the forum is 3 messages per day.
If you want to say "thank you" then use the function "Give good reputation point", which is a green icon "plus" under the nickname of the person, who answered the message.

A user with such an e-mail is already registered...

Postby mpower2k » 18 Apr 2016, 23:36

I have disabled user registration and when someone uses the booking form, if it already used it in the past I get the error:
A user with such an e-mail is already registered. Please login and try again.

What should I modify so that it doesn't check if the email was already used so it permits the user to submit the form multiple times with the same email address?

Thanks!
mpower2k
Stranger
 
Posts: 5
Joined: 04 Apr 2016, 16:58
Reputation point: 0

Re: A user with such an e-mail is already registered...

Postby Foton » 20 Apr 2016, 11:08

In the file protected\modules\booking\controllers\MainController.php change code from
Code: Select all
$userData = User::createUser(array(
                            'email' => $booking->useremail,
                            'username' => $booking->username,
                            'phone' => $booking->phone,
                            'activatekey' => User::generateActivateKey()
                        ));

                        if ($userData) {
                            $user = $userData['userModel'];
                            $user->id = $userData['id'];
                            $user->password = $userData['password'];
                            $user->email = $userData['email'];
                            $user->username = $userData['username'];
                            $user->activatekey = $userData['activatekey'];
                            $user->activateLink = $userData['activateLink'];

                            if($payImmediately){
                                $identity = new UserIdentity($userData['email'], $userData['password']);
                                if($identity->authenticate() && Yii::app()->user->login($identity, 2592000)){
                                    Yii::app()->user->setState('attempts-login', 0);
                                    User::updateUserSession();
                                    User::updateLatestInfo(Yii::app()->user->id, Yii::app()->controller->currentUserIp);
                                }
                            }

                            $notifier = new Notifier;
                            $notifier->raiseEvent('onNewUser_'.param('user_registrationMode'), $user, array(
                                'user' => $userData['userModel'],
                                'forceSendUser' => true
                            
));
                        } else {
                            $booking->addError('', tt('Error User Registration', 'booking'));
                        } 

to
Code: Select all
if(param('useUserRegistration', 1)) {
                        $userData = User::createUser(array(
                            'email' => $booking->useremail,
                            'username' => $booking->username,
                            'phone' => $booking->phone,
                            'activatekey' => User::generateActivateKey()
                        ));

                        if ($userData) {
                            $user = $userData['userModel'];
                            $user->id = $userData['id'];
                            $user->password = $userData['password'];
                            $user->email = $userData['email'];
                            $user->username = $userData['username'];
                            $user->activatekey = $userData['activatekey'];
                            $user->activateLink = $userData['activateLink'];

                            if($payImmediately){
                                $identity = new UserIdentity($userData['email'], $userData['password']);
                                if($identity->authenticate() && Yii::app()->user->login($identity, 2592000)){
                                    Yii::app()->user->setState('attempts-login', 0);
                                    User::updateUserSession();
                                    User::updateLatestInfo(Yii::app()->user->id, Yii::app()->controller->currentUserIp);
                                }
                            }

                            $notifier = new Notifier;
                            $notifier->raiseEvent('onNewUser_'.param('user_registrationMode'), $user, array(
                                'user' => $userData['userModel'],
                                'forceSendUser' => true
                            
));
                        } else {
                            $booking->addError('', tt('Error User Registration', 'booking'));
                        }
                    } 


in files protected\modules\booking\models\Booking.php and protected\modules\booking\models\SimpleformModel.php change code from
Code: Select all
public function myUserEmailValidator() {
        if (Yii::app()->user->isGuest) { 

to
Code: Select all
public function myUserEmailValidator() {
        if (Yii::app()->user->isGuest && param('useUserRegistration', 1)) { 

in file protected\modules\bookingtable\models\Bookingtable.php change code from
Code: Select all
public static function addRecord(Booking $booking, User $user, $status = self::STATUS_NEW) {
        $dateStart = Yii::app()->dateFormatter->format('yyyy-MM-dd', CDateTimeParser::parse($booking->date_start, Booking::getYiiDateFormat()));
        $dateEnd = Yii::app()->dateFormatter->format('yyyy-MM-dd', CDateTimeParser::parse($booking->date_end, Booking::getYiiDateFormat()));

        $model = new Bookingtable;
        $model->active = $status;
        $model->apartment_id = $booking->apartment_id;
        $model->username = $booking->username;
        $model->email = $booking->useremail;
        $model->phone = $booking->phone;
        $model->date_start = $dateStart;
        $model->date_end = $dateEnd;
        $model->time_in = $booking->time_in;
        $model->time_out = $booking->time_out;
        $model->comment = $booking->comment;
        $model->user_ip = $booking->user_ip;
        $model->user_ip_ip2_long = $booking->user_ip_ip2_long;
        $model->sender_id = $user->id;
        $model->amount = $booking->amount;
        $model->num_guest = $booking->num_guest;

        $model->save(false);

        return $model;
    } 

to
Code: Select all
public static function addRecord(Booking $booking, $user, $status = self::STATUS_NEW) {
        $dateStart = Yii::app()->dateFormatter->format('yyyy-MM-dd', CDateTimeParser::parse($booking->date_start, Booking::getYiiDateFormat()));
        $dateEnd = Yii::app()->dateFormatter->format('yyyy-MM-dd', CDateTimeParser::parse($booking->date_end, Booking::getYiiDateFormat()));

        $model = new Bookingtable;
        $model->active = $status;
        $model->apartment_id = $booking->apartment_id;
        $model->username = $booking->username;
        $model->email = $booking->useremail;
        $model->phone = $booking->phone;
        $model->date_start = $dateStart;
        $model->date_end = $dateEnd;
        $model->time_in = $booking->time_in;
        $model->time_out = $booking->time_out;
        $model->comment = $booking->comment;
        $model->user_ip = $booking->user_ip;
        $model->user_ip_ip2_long = $booking->user_ip_ip2_long;
        $model->sender_id = $user ? $user->id : 0;
        $model->amount = $booking->amount;
        $model->num_guest = $booking->num_guest;

        $model->save(false);

        return $model;
    } 
Foton
Web Developer
Web Developer
 
Posts: 117
Joined: 26 Jan 2012, 14:58
Reputation point: 1


Return to Issues

Who is online

Users browsing this forum: No registered users and 12 guests

cron