Commit 284ef7f0 authored by bgm's avatar bgm
Browse files

Merge branch 'wp-civicrm-mailer#1' into 'master'

coopsymbiotic/wordpress/wp-civicrm-mailer#1 avoid creating duplicate contact in CiviCRM

See merge request coopsymbiotic/wordpress/wp-civicrm-mailer!1
parents 0f5f54ee d50f6a28
......@@ -41,6 +41,21 @@ class CivicrmMailerHTTPMailer extends \PHPMailer
if ($user && $user->ID) {
$uf_id = $user->ID;
}
else {
// special case of email change request
// check if a _new_email correspond in wp_usermeta
$args = [
'fields' => 'user_id',
'meta_key' => '_new_email',
'meta_value' => $recipient,
'meta_compare' => 'LIKE',
];
$q = new \WP_User_Query($args);
$res = $q->get_results();
// if we have only one result, assume it's the user we need
if (count($res) == 1 && isset($res[0])) $uf_id = $res[0];
}
if ($uf_id) {
try {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment