diff --git a/Xero.php b/Xero.php index 731293a..74bdf53 100644 --- a/Xero.php +++ b/Xero.php @@ -71,7 +71,12 @@ class Xero { // //sync users to wordpress system //does not work for too many users or employees - public function sync_users(){ + public function sync_users($mininterval){ + $this->usage(); + $this->minimum_sync_interval_in_seconds = $mininterval; + $msg="Sync users with minimum interval set to $mininterval \n"; + $this->logConsole($msg); + try{ $this->sync_clients(); $this->sync_employees(); @@ -199,4 +204,16 @@ class Xero { echo $str; } } + + private function usage(){ + $msg = "_____________________________________________\n"; + $msg .= "run this command at public_html/, where wp-config.php exist \n"; + $msg .= "wp sync_users --mininterval=6000 \n"; + $msg .= "6000 means those users synced within 6000 seconds will be bypassed \n"; + $msg .= "to sync everything \n"; + $msg .= "wp sync_users --mininterval=0 \n"; + $msg .= "but it may hit XERO rate limit, 60call/sec, 5000/day \n"; + $msg .= "---------------------------------------------\n"; + $this->logConsole($msg); + } } \ No newline at end of file diff --git a/ts.php b/ts.php index 99f3b91..e28eed2 100644 --- a/ts.php +++ b/ts.php @@ -96,10 +96,13 @@ class AcareOffice{ $a=1; return; } + + // Usage: `wp sync_users --mininterval=123 public function sync_user_cli($args = array(), $assoc_args = array()){ - $this->cli = true; - echo "running sync user from command line;\n"; - $this->xero->sync_users(); + $arguments = wp_parse_args( $assoc_args, array( + 'mininterval' => 600, + ) ); + $this->xero->sync_users($arguments['mininterval']); return; } }