2

I need to run a cron job on a wordpress site which in the script includes the function get_users() however because this script is a single file it does not include any of the core wordpress files.

My question is which files do I need to include in order for the get_users() function to run.

Any help would be hugely appreciated.

Best regards

David

1 Answers1

5

You need to require wp-load.php file. Include following code in the beginning of your file:

$path  = '';
if(!defined('WP_LOAD_PATH')){
    $root = dirname(__FILE__).'/';

    if(file_exists($root.'wp-load.php')){
        define('WP_LOAD_PATH',$root);
    }else{
        if(file_exists($path.'wp-load.php')){
            define('WP_LOAD_PATH',$path);
        }else{
            exit("Cannot find wp-load.php");
        }
    }
}
require_once(WP_LOAD_PATH.'wp-load.php');
Avag Sargsyan
  • 2,437
  • 3
  • 28
  • 41