@@ -, +, @@ EmailMustBeUnique - Set PatronSelfRegistrationEmailMustBeUnique to "consider" - Register a new patron with an existing email address - Use a non-existent email address - Edit your patron details - Modify some infos - Modify your email address with an existing one --- opac/opac-memberentry.pl | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) --- a/opac/opac-memberentry.pl +++ a/opac/opac-memberentry.pl @@ -228,6 +228,7 @@ elsif ( $action eq 'update' ) { }); my %borrower = ParseCgiForBorrower($cgi); + $borrower{borrowernumber} = $borrowernumber; my %borrower_changes = DelEmptyFields(%borrower); my @empty_mandatory_fields = @@ -392,7 +393,17 @@ sub CheckForInvalidFields { 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; + my $patrons_with_same_email = Koha::Patrons->search( + { + email => $borrower->{email}, + ( + exists $borrower->{borrowernumber} + ? ( borrowernumber => + { '!=' => $borrower->{borrowernumber} } ) + : () + ) + } + )->count; if ( $patrons_with_same_email ) { push @invalidFields, "duplicate_email"; } --