3

I am getting

Fatal error: Call to undefined function add_filter() in example.com/wp-config.php on line 20

after adding

add_filter( 'auto_update_plugin', '__return_true' );

to wp-config.php

My plugins.php file is present and add_filter() is defined inside of it.

I just want to enable automatic updates for core, plugins and thems.

What am I doing wrong?

3 Answers 3

4

There is a section that should look like this:

defined( 'ABSPATH' ) || define( 'ABSPATH', __DIR__ . '/' );
require_once( ABSPATH . 'wp-settings.php' );

add_filter() is available after that, you are probably using it too early.

2
  • That's it, thanks! The Automatic Background Updates Wordpress codex entry (codex.wordpress.org/Configuring_Automatic_Background_Updates) should probably be updated with this info, but I have no idea how.
    – SkyHiRider
    Apr 21, 2014 at 23:45
  • 1
    @SkyHiRider I made that update. :) You need an account on wordpress.org to edit the wiki pages.
    – fuxia
    Apr 22, 2014 at 0:59
2

The recommended best practice is to use a mu-plugin for this. Adding add_filter()s to wp-config.php directly can cause all kinds of other problems and conflicts.

0

I used wp-cli and got this error.

I had in wp-config.php at bottom:

remove_filter('template_redirect','redirect_canonical');

instead i put to top

define('WP_HOME','http://example.com');

define('WP_SITEURL','http://example.com');

it solved my problem

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.