How to fix “Warning: Use of undefined constant” error with WordPress after upgrading to PHP 7.2

The issue

I recently upgraded my wordpress blog from PHP 7.1 to 7.2. After that, I started getting an error on the top of the pages: “Warning: Use of undefined constant”, pointing at what I  previously set on wp-config.php: DISABLE_WP_CRON

I used this to disable the cron triggering with user access, instead I set up a manually cron job that runs every 20 minutes and open the wp-cron.php

The instructions I used asked to use the following format:

warning: use of undefined constant fix

Turns out PHP 7.2 does not like it.

The solution to the “use of undefined constant” warning

The undefined constant error is quite generic, but in this case the fix is quite simple. Just declare like this instead:

define( ‘DISABLE_WP_CRON’, ‘true’);

I suspect some plugins might be affected by this too, but so far all the stuff I’m using is very up to date, so no issues yet!

For other topics related to WordPress or PHP, check out the PHP section on my blog.

Categorized as PHP

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.