diff --git a/includes/class-gdpr-audit-log.php b/includes/class-gdpr-audit-log.php index 74318891..b0d66627 100755 --- a/includes/class-gdpr-audit-log.php +++ b/includes/class-gdpr-audit-log.php @@ -67,10 +67,13 @@ private static function decrypt( $key, $data ) { * @param string $input The string to be logged. */ public static function log( $user_id, $input ) { - $user = get_user_by( 'ID', $user_id ); - $date = '[' . date( 'Y/m/d H:i:s' ) . '] '; - $encrypted = self::crypt( $user->user_email, $date . $input ); - add_user_meta( $user_id, 'gdpr_audit_log', $encrypted ); + $user = get_user_by( 'ID', $user_id ); + + if ( $user instanceof WP_User ) { + $date = '[' . date( 'Y/m/d H:i:s' ) . '] '; + $encrypted = self::crypt( $user->user_email, $date . $input ); + add_user_meta( $user_id, 'gdpr_audit_log', $encrypted ); + } } /**