Title: Calling a non-static method statically
Last modified: November 21, 2022

---

# Calling a non-static method statically

 *  [jayahn4](https://wordpress.org/support/users/jayahn4/)
 * (@jayahn4)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/calling-a-non-static-method-statically/)
 * Since updating to PHP 8.0, I’m getting the following error:
 * `PHP message: PHP Fatal error: Uncaught TypeError: call_user_func(): Argument#
   1 ($callback) must be a valid callback, non-static method PMProRH_Field::saveFile()
   cannot be called statically in /www/austa_486/public/wp-content/plugins/pmpro-
   register-helper/pmpro-register-helper.php:937`
 * I’ve taken a look at pmpro-register-helper.php line 937, which contains the following:
 *     ```
       if(!empty($field->save_function))
           call_user_func($field->save_function, $user_id, $field->name, $_POST[$field->name]);
       ```
   
 * And then at class.field.php:
 *     ```
       elseif($this->type == "file")
       {
       	//use the file save function
       	$this->save_function = array("PMProRH_Field", "saveFile");
       }
       ```
   
 * Any thoughts?
    -  This topic was modified 3 years, 6 months ago by [jayahn4](https://wordpress.org/support/users/jayahn4/).

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

 *  Thread Starter [jayahn4](https://wordpress.org/support/users/jayahn4/)
 * (@jayahn4)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/calling-a-non-static-method-statically/#post-16217759)
 * So I went into classes/class.field.php and edited line 146 and added ‘static’
 * From
    `function saveFile($user_id, $name, $value)`
 * To
    `static function saveFile($user_id, $name, $value)`
 * And now it is working. Since PHP 8.0 is more strict with syntax, it doesn’t allow
   static calling of non-static methods. Perhaps this should be updated all throughout
   the plugin, or does anybody have any other workarounds?
    -  This reply was modified 3 years, 6 months ago by [jayahn4](https://wordpress.org/support/users/jayahn4/).
 *  [Strusbobbin](https://wordpress.org/support/users/strusbobbin/)
 * (@strusbobbin)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/calling-a-non-static-method-statically/#post-16536289)
 * WordPress should be updated in its entirety to be completely honest, along with
   a whole boat load of plugins. There are plenty of websites out there claiming
   that WP is 100% compatible with PHP 8+, but this is a lie as I’m writing thins.
   Install a plugin such as Query Monitor and you’ll very quickly see how incompatible
   it actually is.
 * Expect another 6 months+ before this issue is sorted. In the meanwhile “hacks”
   such as yours will need to be the order of the day. Well done for figuring it
   out btw.
    -  This reply was modified 3 years, 3 months ago by [Strusbobbin](https://wordpress.org/support/users/strusbobbin/).

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

The topic ‘Calling a non-static method statically’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/pmpro-register-helper_eec9bb.svg)
 * [Custom User Profile Fields for User Registration & Member Frontend Profiles with Paid Memberships Pro](https://wordpress.org/plugins/pmpro-register-helper/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/pmpro-register-helper/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/pmpro-register-helper/)
 * [Active Topics](https://wordpress.org/support/plugin/pmpro-register-helper/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/pmpro-register-helper/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/pmpro-register-helper/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Strusbobbin](https://wordpress.org/support/users/strusbobbin/)
 * Last activity: [3 years, 3 months ago](https://wordpress.org/support/topic/calling-a-non-static-method-statically/#post-16536289)
 * Status: not resolved