Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not working the code #23

Open
vikptest opened this issue Apr 8, 2022 · 0 comments
Open

not working the code #23

vikptest opened this issue Apr 8, 2022 · 0 comments

Comments

@vikptest
Copy link

vikptest commented Apr 8, 2022

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")
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant