Skip to content

not working the code #23

Open
Open
@vikptest

Description

@vikptest

Thanks for the solution , i am using this code to run clear cache feature when saving a post in wordpress. But my run_action () not executing .Can you please help:
This is my code in functions.php
include 'wp-async-task.php';

class ApiStatusTask extends WP_Async_Task {

protected $action = 'save_post';

/**

  • Prepare data for the asynchronous request
  • @throws Exception If for any reason the request should not happen
  • @param array $data An array of data sent to the hook
  • @return array
    */
    protected function prepare_data( $data ) {
    return array(
    'api_url' => $data[0]
    );
    }

/**

  • Run the async task action
    */
    protected function run_action() {
    if(isset($POST['api_url'])){
    do_action("wp_async
    $this->action", $_POST['api_url']);
    }
    // cache clear feature
    }

}

add_action( 'wp_async_save_post', 'josh_send_to_api' );
function josh_send_to_api( $id ) {
wp_mail("[email protected]","subject","Content")
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions