Send new post content via webhook
add_action('publish_post', function( $ID, $post ) {
if ($post->post_type == 'post') {
$webhook_url = 'https://example.com/webhook-endpoint';
$response = wp_remote_post(
$webhook_url,
array(
'method' => 'POST',
'body' => json_encode( $post ),
'headers' => array('Content-Type' => 'application/json')
)
);
}
}, 10, 2);
Comments