public function cron()
    {

        //Increase memory and runtime
        ini_set('memory_limit', "512M");
        ini_set('max_execution_time', 60 * 60 * 60);

        //Include required resources
        require_once(ABSPATH . 'wp-admin/includes/user.php');

        //Step 1: Create diffs
        $createAccounts = $this->diffUserAccounts(true);
        $deleteAccounts = $this->diffUserAccounts(false);

        //Sanity check, many users to remove?
        $maxDeleteLimit = isset($_GET['maxDeletelimit']) ? (int) $_GET['maxDeletelimit'] : 100;

        if (count($deleteAccounts) > $maxDeleteLimit) {
            if (is_main_site()) {
                if (get_transient('ad_api_too_many_deletions') !== 1) {

                    //Send mail
                    wp_mail(
                        get_option('admin_email'),
                        "Ad-integration plugin",
                        __("To many user deletions in queue (" . count($deleteAccounts) . "/" . $maxDeleteLimit . ") add https://test.dev/wp-admin/?adbulkimport&maxDeleteLimit=100 to your query to allow number of required deletions.",
                            "adintegration")
                    );

                    //Write to log
                    error_log("Ad-integration plugin: To many user deletions in queue (" . count($deleteAccounts) . "/" . $maxDeleteLimit . ") add https://test.dev/wp-admin/?adbulkimport&maxDeleteLimit=100 to your query to allow number of required deletions.");

                    //Prevent this mail for 24 hours
                    set_transient('ad_api_too_many_deletions', 1, 23 * HOUR_IN_SECONDS);
                }
            }
        } else {
            //Step 2: Delete these accounts
            if (is_array($deleteAccounts) && !empty($deleteAccounts)) {
                foreach ((array)$deleteAccounts as $accountName) {
                    $this->deleteAccount($accountName);
                }
            }
        }

        //Step 3: Create these accounts
        if (is_array($createAccounts) && !empty($createAccounts)) {
            foreach ((array)$createAccounts as $accountName) {
                if (!in_array($accountName, $deleteAccounts)) {
                    $this->createAccount($accountName);
                }
            }
        }

        //Step 4: Schedule profile updates
        $this->scheduleUpdateProfiles();
    }
public function cron()
    {

        //Increase memory and runtime
        ini_set('memory_limit', "512M");
        ini_set('max_execution_time', 60 * 60 * 60);

        //Include required resources
        require_once(ABSPATH . 'wp-admin/includes/user.php');

        //Step 1: Create diffs
        $createAccounts = $this->diffUserAccounts(true);
        $deleteAccounts = $this->diffUserAccounts(false);

        //Sanity check, many users to remove?
        $maxDeleteLimit = isset($_GET['maxDeletelimit']) ? (int) $_GET['maxDeletelimit'] : 100;

        if (count($deleteAccounts) > $maxDeleteLimit) {
            if (is_main_site()) {
                if (get_transient('ad_api_too_many_deletions') !== 1) {

                    //Send mail
                    wp_mail(
                        get_option('admin_email'),
                        "Ad-integration plugin",
                        __("To many user deletions in queue (" . count($deleteAccounts) . "/" . $maxDeleteLimit . ") add https://test.dev/wp-admin/?adbulkimport&maxDeleteLimit=100 to your query to allow number of required deletions.",
                            "adintegration")
                    );

                    //Write to log
                    error_log("Ad-integration plugin: To many user deletions in queue (" . count($deleteAccounts) . "/" . $maxDeleteLimit . ") add https://test.dev/wp-admin/?adbulkimport&maxDeleteLimit=100 to your query to allow number of required deletions.");

                    //Prevent this mail for 24 hours
                    set_transient('ad_api_too_many_deletions', 1, 23 * HOUR_IN_SECONDS);
                }
            }
        } else {
            //Step 2: Delete these accounts
            if (is_array($deleteAccounts) && !empty($deleteAccounts)) {
                foreach ((array)$deleteAccounts as $accountName) {
                    $this->deleteAccount($accountName);
                }
            }
        }

        //Step 3: Create these accounts
        if (is_array($createAccounts) && !empty($createAccounts)) {
            foreach ((array)$createAccounts as $accountName) {
                if (!in_array($accountName, $deleteAccounts)) {
                    $this->createAccount($accountName);
                }
            }
        }

        //Step 4: Schedule profile updates
        $this->scheduleUpdateProfiles();
    }
public function cron ( ) { //Increase memory and runtime ini_set ( 'memory_limit' , "512M" ) ; ini_set ( 'max_execution_time' , 60 * 60 * 60 ) ; //Include required resources require_once ( ABSPATH . 'wp-admin/includes/user.php' ) ; //Step 1: Create diffs $ createAccounts = $ this -> diffUserAccounts ( true ) ; $ deleteAccounts = $ this -> diffUserAccounts ( false ) ; //Sanity check, many users to remove? $ maxDeleteLimit = isset ( $ _GET [ 'maxDeletelimit' ] ) ? ( int ) $ _GET [ 'maxDeletelimit' ] : 100 ; if ( count ( $ deleteAccounts ) > $ maxDeleteLimit ) { if ( is_main_site ( ) ) { if ( get_transient ( 'ad_api_too_many_deletions' ) !== 1 ) { //Send mail wp_mail ( get_option ( 'admin_email' ) , "Ad-integration plugin" , __ ( "To many user deletions in queue (" . count ( $ deleteAccounts ) . "/" . $ maxDeleteLimit . ") add https://test.dev/wp-admin/?adbulkimport&maxDeleteLimit=100 to your query to allow number of required deletions." , "adintegration" ) ) ; //Write to log error_log ( "Ad-integration plugin: To many user deletions in queue (" . count ( $ deleteAccounts ) . "/" . $ maxDeleteLimit . ") add https://test.dev/wp-admin/?adbulkimport&maxDeleteLimit=100 to your query to allow number of required deletions." ) ; //Prevent this mail for 24 hours set_transient ( 'ad_api_too_many_deletions' , 1 , 23 * HOUR_IN_SECONDS ) ; } } } else { //Step 2: Delete these accounts if ( is_array ( $ deleteAccounts ) && ! empty ( $ deleteAccounts ) ) { foreach ( ( array ) $ deleteAccounts as $ accountName ) { $ this -> deleteAccount ( $ accountName ) ; } } } //Step 3: Create these accounts if ( is_array ( $ createAccounts ) && ! empty ( $ createAccounts ) ) { foreach ( ( array ) $ createAccounts as $ accountName ) { if ( ! in_array ( $ accountName , $ deleteAccounts ) ) { $ this -> createAccount ( $ accountName ) ; } } } //Step 4: Schedule profile updates $ this -> scheduleUpdateProfiles ( ) ; }
Cron function, run this class
@return bool
Cron function run this class