WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 3 down vote accepted

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.

share|improve this answer
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 '14 at 23:45
@SkyHiRider I made that update. :) You need an account on wordpress.org to edit the wiki pages. – toscho Apr 22 '14 at 0:59

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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