Anyone use the Action Scheduler API? I am essentially looping and generating scheduled actions. That is all fine and dandy. The first action scheduled is called and the function is executed. However, when the next and subsequent scheduled actions are called, it marks it complete but it doesn't actually execute the function it is hooked to. It almost seems to 'lose' the action. I am not getting any errors in my log as far as debug.log goes.

I've even tried eliminating the API call the my_function() executes below just to see if can simply print to the log. No dice.

My code in a nutshell:

class MyClass {

    public function __construct() {
        $this -> add_actions();
        $this -> my_looping_function();
    public function add_actions() {
        add_action( 'my_function_action', [$this, 'my_function' ], 10, 1 );
    public function my_function( $index ) {
        try {
                make_some_local_api_call( $index );

        } catch ( HttpClientException $e) {
                error_log( 'Caught exception: '. $e -> getMessage() );
    public function my_looping_function() {
        $count = 5;
        for($i = 0; $i < $count; $i++) {
            as_schedule_single_action( time(), 'my_function_action', ['index' => $i], 'my_function_add_batch' );

$class = new MyClass;

I will admit I am a bit of a novice when it comes to OOP. Maybe there is something rudimentary I am missing. I am running on a Local by Flywheel environment. PHP 7.3.5

  • I tested my 'nutshell' code and the scheduled actions all work as they should. 🤦 I'll post an update if I figure out what I am doing wrong and close this. Go figure. It must be something with server resources. Each action has to perform an API call and perhaps I need to add time between actions... May 18 '21 at 21:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.