Attempt to read property “post_type” on null
-
Hello!
I am using the latest version of Elementor and Tutor LMS. This is not a critical error, but my error_log keeps growing because of this.
The error is the following:
[22-Sep-2023 15:07:24 UTC] PHP Warning: Attempt to read property "post_type" on null in /home/user/domain.com/wp-content/plugins/tutor-lms-elementor-addons/classes/AddonsManager.php on line 43
By adding a null-safe operator (PHP 8+), the error disappears:
line 43: if ( $post?->post_type && $post?->post_type == tutor()->course_post_type ) {}
But taking in mind the compatibility with PHP 7 or lower, the best thing would be:
line 43: if ( $post && $post->post_type && $post->post_type == tutor()->course_post_type ) {}
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Attempt to read property “post_type” on null’ is closed to new replies.