if (!empty($_POST) && !$isLogin) {
$params = $_POST;
$params['email'] = $uniqId;
+ // dev/core#1858 Ensure that if we have a contactID parameter which is set in the Create user Record contact task form
+ // That this contacID value is passed through as the contact_id to the get duplicate contacts function. This is necessary because for Drupal 8 this function gets invoked
+ // Before the civicrm_uf_match record is added where as in D7 it isn't called until the user tries to actually login.
+ if (!empty($params['contactID'])) {
+ $params['contact_id'] = $params['contactID'];
+ }
$ids = CRM_Contact_BAO_Contact::getDuplicateContacts($params, 'Individual', 'Unsupervised', [], FALSE);