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 WordPress with Your Website I first used:
define('WP_USE_THEMES', false); require('../wp-blog-header.php');
But then I had a problem with the downloads, returning a error
404 (file not found).
Lucky me on the footer of the same Codex article there's this suggestion: Fixing false 404 headers on external pages including wp-blog-header.php
Following the suggestion I just used
init which seem enough in my case:
Still, looking into
$GLOBALS I think there's much more done and left than I need.
readfile for the download, the file size maybe huge, the user check is done before, the ideal would be to include a minimal WP as fast as possible and release the WP resources just after the user check, before the
So, there's a way to include a minimal WP for check only the current user, its roles (caps?) and then release/free it?
I seen also
wp-load.php is used and looking/searching around found a lot of no no about including all those
wp-* directly, but all the results where about including from a plugin, not my case, do I still need to worry about including directly?