Today I ran into a situation where I needed the default WP Cron processing to work while a site was protected behind HTTP Basic authentication. If you’re not familiar with the way WP Cron works by default, it spawns an HTTP request to on page load (given a certain set of conditions) and allows that request to sit and process whatever jobs have been registered. When HTTP Basic authentication is active on the site root, though, the request never gets through to wp-cron.php because it gets intercepted by the web server and blocked (because the request isn’t authenticated). To get around that, add the following code into your wp-config.php file: if(!defined('WP_CRON_CUSTOM_HTTP_BASIC_USERNAME')) { define('WP_CRON_CUSTOM_HTTP_BASIC_USERNAME', 'YOUR_USERNAME_HERE'); } if(!defined('WP_CRON_CUSTOM_HTTP_BASIC_PASSWORD')) { define('WP_CRON_CUSTOM_HTTP_BASIC_PASSWORD', 'YOUR_PASSWORD_HERE'); } Then, download this gist and put it inside of the mu-plugins directory. That’s it!
Share This