Title: PHP 8.1 causing errors
Last modified: November 29, 2022

---

# PHP 8.1 causing errors

 *  [slramela](https://wordpress.org/support/users/slramela/)
 * (@slramela)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/php-8-1-causing-errors/)
 * Using PHP 8.1, we get these PHP errors:
 * `PHP Warning: Attempt to read property "ID" on null in */wp-content/plugins/pagerestrict/
   pagerestrict.php on line 155
    */wp-content/plugins/pagerestrict/pagerestrict.
   php on line 163
 * We are using latest version of the plugin.
 * Both are fixed by changing line 152 of the pagerestrict.php file from
 * `if ( !\is_user_logged_in() && $pr_check ) :`
 * to
 * `if ( !\is_user_logged_in() && $pr_check && !is_null($post) ) :`
 * I hope this fix gets rolled out soon since PHP 7 is nearing its end of life and
   a lot of people will be changing to PHP8 soon. (January 1st, 2023)
    -  This topic was modified 3 years, 6 months ago by [slramela](https://wordpress.org/support/users/slramela/).

Viewing 1 replies (of 1 total)

 *  [uh2112](https://wordpress.org/support/users/razorzz/)
 * (@razorzz)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/php-8-1-causing-errors/#post-16388590)
 * I think this is the same for me, except client is on PHP 8.0.
 * Critical error:
   PHP Notice: Trying to get property ‘ID’ of non-object in /*/httpdocs/
   wp-content/plugins/pagerestrict/pagerestrict.php on line 155

Viewing 1 replies (of 1 total)

The topic ‘PHP 8.1 causing errors’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/pagerestrict.svg)
 * [Page Restrict](https://wordpress.org/plugins/pagerestrict/)
 * [Support Threads](https://wordpress.org/support/plugin/pagerestrict/)
 * [Active Topics](https://wordpress.org/support/plugin/pagerestrict/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/pagerestrict/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/pagerestrict/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [uh2112](https://wordpress.org/support/users/razorzz/)
 * Last activity: [3 years, 4 months ago](https://wordpress.org/support/topic/php-8-1-causing-errors/#post-16388590)
 * Status: not resolved