From: Steve Sutton Date: Fri, 7 Sep 2018 19:05:01 +0000 (-0400) Subject: Fix if no contact id or no wpUser X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=dd421300dfbb37affa2267013d169ccddc2fbe5f;p=WP-Plugins%2Fglm-member-db-contacts.git Fix if no contact id or no wpUser if not found then nothing --- 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 )