From dd421300dfbb37affa2267013d169ccddc2fbe5f Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Fri, 7 Sep 2018 15:05:01 -0400 Subject: [PATCH] Fix if no contact id or no wpUser if not found then nothing --- classes/data/dataContacts.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/classes/data/dataContacts.php b/classes/data/dataContacts.php index bc3ad87..4276d14 100644 --- a/classes/data/dataContacts.php +++ b/classes/data/dataContacts.php @@ -836,9 +836,13 @@ class GlmDataContacts extends GlmDataAbstract public function updateContactRole( $contact_id, $old_role, $new_role ) { $user_id = $this->getWpUserId( $contact_id ); - $wpUser = get_user_by( 'id', $user_id ); - $wpUser->remove_role( $old_role ); - $wpUser->add_role( $new_role ); + if ( $user_id ) { + $wpUser = get_user_by( 'id', $user_id ); + if ( $wpUser ) { + $wpUser->remove_role( $old_role ); + $wpUser->add_role( $new_role ); + } + } } public function getContactIdByRefDest( $ref_dest ) -- 2.17.1