Skip to content

Instantly share code, notes, and snippets.

@daliborgogic
Created September 5, 2018 11:50
Show Gist options
  • Save daliborgogic/f9bfc7500268987113d58ff626fa7782 to your computer and use it in GitHub Desktop.
Save daliborgogic/f9bfc7500268987113d58ff626fa7782 to your computer and use it in GitHub Desktop.
function notify_post ($post_id) {
$request = new WP_REST_Request('GET', '/wp/v2/posts/' . $post_id);
$response = rest_do_request($request);
$status = $response->get_status();
$data = $response->get_data();
$callback_uri = 'https://example.com';
wp_safe_remote_post($callback_uri, array('body' => json_encode($data)));
}
add_action('post_updated', 'notify_post');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment