From b931b76d8c389c7d3b99673d0efdf806ba7bc2ef Mon Sep 17 00:00:00 2001 From: Christian Wach Date: Tue, 31 Jan 2023 10:39:32 +0000 Subject: [PATCH] Prevent PHP warnings when no WordPress user is found --- CRM/Utils/System/WordPress.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CRM/Utils/System/WordPress.php b/CRM/Utils/System/WordPress.php index 533e3078b7..2856631fc8 100644 --- a/CRM/Utils/System/WordPress.php +++ b/CRM/Utils/System/WordPress.php @@ -581,15 +581,15 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base { */ public function loadUser($user) { $userdata = get_user_by('login', $user); - if (!$userdata->data->ID) { + if (empty($userdata->ID)) { return FALSE; } - $uid = $userdata->data->ID; + $uid = $userdata->ID; wp_set_current_user($uid); $contactID = CRM_Core_BAO_UFMatch::getContactId($uid); - // lets store contact id and user id in session + // Lets store contact id and user id in session. $session = CRM_Core_Session::singleton(); $session->set('ufID', $uid); $session->set('userID', $contactID); @@ -616,10 +616,10 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base { */ public function getUfId($username) { $userdata = get_user_by('login', $username); - if (!$userdata->data->ID) { + if (empty($userdata->ID)) { return NULL; } - return $userdata->data->ID; + return $userdata->ID; } /** -- 2.25.1