diff --git a/include/ajax.forms.php b/include/ajax.forms.php index a04c327a0f9153135cc57dfdc7099d6b6b3da0fd..c196ea2b2f4d3c503f4e77fe50be6bf9f279416d 100644 --- a/include/ajax.forms.php +++ b/include/ajax.forms.php @@ -70,6 +70,18 @@ class DynamicFormsAjaxAPI extends AjaxController { $valid &= $cd->isValid(); } + if ($valid) { + foreach ($custom_data as $cd) + foreach ($cd->getFields() as $f) + if ($f->get('name') == 'email') + $email = $f; + $u = User::lookup(array('emails__address'=>$email->getClean())); + if ($u && $u->id != $user_id) { + $valid = false; + $email->addError('Email is assigned to another user'); + } + } + if (!$valid) { include(STAFFINC_DIR . 'templates/user-info.tmpl.php'); return;