diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt index 77e17e31c7..66db3065c9 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt @@ -65,6 +65,9 @@ [% IF field == "password_match" %]
  • Passwords do not match! password
  • [% END %] [% IF field == "password_invalid" %]
  • Password does not meet minimum requirements! password
  • [% END %] [% IF field == "password_spaces" %]
  • Password contains leading and/or trailing spaces! password
  • [% END %] + [% IF field == "duplicate_email" %] +
  • This email address already exists in our database.
  • + [% END %] [% END %] Please correct the errors and resubmit. diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl index 8b5ade944f..6dcc832693 100755 --- a/opac/opac-memberentry.pl +++ b/opac/opac-memberentry.pl @@ -352,7 +352,14 @@ sub CheckForInvalidFields { my $borrower = shift; my @invalidFields; if ($borrower->{'email'}) { - push(@invalidFields, "email") if (!Email::Valid->address($borrower->{'email'})); + unless ( Email::Valid->address($borrower->{'email'}) ) { + push(@invalidFields, "email"); + } elsif ( C4::Context->preference("PatronSelfRegistrationEmailMustBeUnique") ) { + my $patrons_with_same_email = Koha::Patrons->search( { email => $borrower->{email} })->count; + if ( $patrons_with_same_email ) { + push @invalidFields, "duplicate_email"; + } + } } if ($borrower->{'emailpro'}) { push(@invalidFields, "emailpro") if (!Email::Valid->address($borrower->{'emailpro'}));