Title: PHP Error in ShortcodeParser with PHP 8.1
Last modified: November 11, 2022

---

# PHP Error in ShortcodeParser with PHP 8.1

 *  Resolved [reasonx](https://wordpress.org/support/users/reasonx/)
 * (@reasonx)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/php-error-in-shortcodeparser-with-php-8-1/)
 * Wordpress 6.1
    ProfilePress 4.3.1 PHP 8.1
 * Hi,
 * we are upgrading to PHP 8.1 at the moment because the PHP 7.4 security support
   is ending in a few days. The switch to 8.1 was successful with WordPress 6.1 
   so far but the only plugin left that throws an error is ProfilePress :D.
 * The error occurs in that file:
 * wp-content/plugins/wp-user-avatar/src/ShortcodeParser/Builder/FieldsShortcodeCallback.
   php
 * on line 39
 * `if (method_exists($this->current_user, 'exists') && $this->current_user->exists())
   $flag = true;`
 * this is the error message:
 * > TypeError: method_exists(): Argument #1 ($object_or_class) must be of type 
   > object|string, null given
 * So it seems like $this->current_user is null at that point which throws the error.
   But the error is only thrown if we switch to PHP 8.1 – As soon as we switch back
   to 7.4 the error has gone away. Indeed method_exists() was updated in PHP8 and
   it now throws an error in such a case apparently.
 * It would be nice, if you could provide a fix for that in an upcoming version.
   Thank you very much.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Collins Agbonghama](https://wordpress.org/support/users/collizo4sky/)
 * (@collizo4sky)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/php-error-in-shortcodeparser-with-php-8-1/#post-16189480)
 * We’ve fixed this and will ensure compatibility with PHP 8 in other areas in the
   next update. Below is the fix
 *     ```
       $flag = false;
               if (function_exists('wp_get_current_user')) {
                   $this->get_current_user();
                   if (is_object($this->current_user) && method_exists($this->current_user, 'exists') && $this->current_user->exists()) {
                       $flag = true;
                   }
               }
       ```
   
 * Thanks for letting us know.
 *  Thread Starter [reasonx](https://wordpress.org/support/users/reasonx/)
 * (@reasonx)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/php-error-in-shortcodeparser-with-php-8-1/#post-16189761)
 * Wow, what a fast answer 🙂 Thank you very much.
 *  Plugin Author [Collins Agbonghama](https://wordpress.org/support/users/collizo4sky/)
 * (@collizo4sky)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/php-error-in-shortcodeparser-with-php-8-1/#post-16189782)
 * [@reasonx](https://wordpress.org/support/users/reasonx/) happy to always help.
   Maybe consider leaving us a review.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘PHP Error in ShortcodeParser with PHP 8.1’ is closed to new replies.

 * ![](https://ps.w.org/wp-user-avatar/assets/icon-256x256.png?rev=2532486)
 * [Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress](https://wordpress.org/plugins/wp-user-avatar/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-user-avatar/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-user-avatar/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-user-avatar/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-user-avatar/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-user-avatar/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Collins Agbonghama](https://wordpress.org/support/users/collizo4sky/)
 * Last activity: [3 years, 6 months ago](https://wordpress.org/support/topic/php-error-in-shortcodeparser-with-php-8-1/#post-16189782)
 * Status: resolved