Using plugin functionality in external php script not working

I am encountering a strange problem which I couldn’t solve so far. I’m calling a .php script via cronjob (Debian/GNU Linux). To use wordpress functionailty I added: define(‘WP_USE_THEMES’, false); require( ‘/full/path/to/wp-blog-header.php’ ); Now database queries and default wordpress functionality all works fine, but I also call some functions provided by a plugin (namely advanced custom … Read more

Force pdf download not working when include blog-header.php

I have this code which works in a file called downloads/download.php: <?php header(‘Content-type: application/octet-stream’); header(‘Content-Disposition: attachment; filename=”file.pdf”‘); readfile(‘file.pdf’); ?> It correctly prompts to download file.pdf. I need to track downloads so I want to make use of various WP functions. To bring the page inside WP I added blog-header.php like so: <?php define(‘WP_USE_THEMES’, false); require(‘../wp-blog-header.php’); … Read more

there’s a way to include a minimal WP for check only the current user, its roles (caps?) and then release/free it?

I need to count how many times a file in a particular sub-directory is downloaded and track who downloaded it. I’m using a Php file to do it, it isn’t a WP file but I need to include WP to get the current user (if authenticated) and its roles (and maybe caps). Looking at Integrating … Read more

What is the correct way to use WordPress functions outside WordPress files?

I read about 2 methods for initializing WordPress function outside of WordPress files so We can use these functions on any page or website outside the WordPress blog. Which one of these 2 methods is the correct one? What are the use cases for each method if both are correct? What is the deference between … Read more