PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'remove_wpcf7' not found or invalid function name

13,173

Solution 1

Finally found the solution ... It related to the Server Time Settings.

If anyone else is experiencing a similar issue with their Google Authentication feature, you will need to ensure your Server's time settings are in sync with the 'Internet's Clock'.

  1. Login into your VPS;
  2. Head to Tools & Settings > General Settings > System Time;
  3. Here, you should have a screen that looks something like:

    enter image description here

  4. Ensure that the Date & Time > Update system time is deselected;

  5. Ensure that Network time > Synchronize system time is selected;
  6. Then within Network time > Domain name or IP, enter 3.pool.ntp.org and select 'Ok'. It was this step, which I needed to do in order to fix my own issue.

Solution 2

Find in code any reference to 'remove_wpcf7' and find method is assigned in filter/hook. In this case you can find, for example a method inside a class called incorrectly. For example: add_filter('filter_name', 'method');. You can fix, for example, by add: add_filter('filter_name', array($this, 'method')); or if method is static: add_filter('filter_name', array(CLASSNAME::class, 'method'));

Hope this help you

===

UPDATE

Edit wp-includes/class-wp-hook.php line 73 and add:

    public function add_filter( $tag, $function_to_add, $priority, $accepted_args ) {
        if ($function_to_add === 'remove_wpcf7') {
            throw new \Exception('Exception');
        }
        [...]
    }

Get trace of this uncaught exception (if you can use xdebug extension it be better) and you will see line is creating this filter.

Share:
13,173
Craig
Author by

Craig

Whilst I have dabbled with WordPress theme templates for some time now, I am fairly new to php coding myself. Excuse me if any of my questions are scattergun but I am keen on learning and believe the best way to learn is through doing. Once I have got to grips with php and more confident with how it all works, I will hopefully be able to help others here who are looking to become competent in using php.

Updated on June 13, 2022

Comments

  • Craig
    Craig almost 2 years

    Apologies for this broad question but I am not hugely familiar with the Error Log entries at present. Any directives on where to begin the relevant research, would be greatly appreciated.

    For the past 12 months, I have had the Google Authenticate Plugin, installed on a WordPress powered eCommerce website I work on. There had been no issues with the Plugin until a recent VPS and WordPress update. Since said updates, the Google Authenticate Plugin does not recognise any of the inputted codes. I am not sure if the error is being triggered by the WordPress update or the VPS itself.

    I then checked the error_log and saw the below entry when trying to use the Google Authenticate Plugin:

    mod_fcgid: stderr: PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'remove_wpcf7' not found or invalid function name in /var/www/vhosts/example.com/httpdocs/wp-includes/class-wp-hook.php on line 286, referer: https://www.example.com/wp-admin/plugins.php
    

    Troubleshooting

    As standard, I deactivated all Plugins (Except for the WooCommerce Plugin) as well as the WordPress Theme I had created. I then simply activated WordPress' Twenty Seventeen Theme. The error still persisted; leaving me wondering just what is causing the issue.

    I can see there is a reference to WordPress' core files. Maybe there is some incompatibilities?

    Any directives on this, would be greatly appreciated ... Even if to just help me expand on this question.

    • Machavity
      Machavity over 5 years
      Uninstall Contact Form 7. I bet the error goes away
    • Craig
      Craig over 5 years
      I am using PHP Version: 7.0.31. I have uninstalled all Plugins (Including Contact Form 7) but the Error Log entry still gets generated.
    • Ivnhal
      Ivnhal over 5 years
      Have you tried to re-sync Authenicator on your device?
    • Ivnhal
      Ivnhal over 5 years
      If this won't help, search for the 'remove_wpcf7' string over all the plugins files in the wp-content/plugins folder. This way you will get the plugin that causes the issue. When found, post the fragment of the code with this function here, so we can check what is wrong there.
    • Craig
      Craig over 5 years
      @IvnH: Thanks for your suggestion. I have re-synced Google Authenticator, although it did say that the Times were all correct. Furthermore, the Google Authenticator App (on the Mobile/Cell) works with other websites, which are not hosted on my VPS.
    • Craig
      Craig over 5 years
      @IvnH: I had deactivated all of the Plugin, yet the error still persisted. I even deleted all the Plugins (except WooCommerce and Google Authenticate) but still no success. Could the issue lie within the referenced wp-includes/class-wp-hook.php file? This could explain the issue arising after a WordPress update.
    • Ivnhal
      Ivnhal over 5 years
      @Craig, I would suggest to try with another theme also.
    • Craig
      Craig over 5 years
      @IvnH: I have tried several Themes, including WordPress' default but still the error persists. I've also reinstalled and old version of WordPress (the last WordPress version where the Plugin worked) but the error was still present. You don't think the issue could be to do with the MySql Database?
    • Santiago Cerro López
      Santiago Cerro López over 5 years
      @Craig Edit wp-includes/class-wp-hook.php line 73, add: if ($function_to_add === 'remove_wpcf7') trow new Exception('Exception'), get trace of this uncaught exception and you will see line is creating this filter.
  • Ivnhal
    Ivnhal over 5 years
    You're right, for sure, but it was suggested already in the comments and Craig deactivated all his plugins.
  • Santiago Cerro López
    Santiago Cerro López over 5 years
    @IvnH I just update my answer, I'm really sure that is an add_filter method lost in some part of code. With this "kind" of debug, I hope this code can be found.
  • Craig
    Craig over 5 years
    Thanks for your suggestion here. Unfortunately, this entry takes the website offline.
  • Santiago Cerro López
    Santiago Cerro López over 5 years
    @Craig I think you're on localhost. Revert this change and see error log. Now you have the trace and you can see the file is adding this method.
  • Craig
    Craig over 5 years
    @SantiagoCerroLópez: Thanks for your time with my question but I have now found the solution, as per my answer here. :-)