Take a look at some of WordPress’s Actions & Filters – in particular, you might want something like publish_post
:
function my_custom_post_action( $post_id, $post ) {
// Send out data to your service using something
// like wp_remote_request:
// https://codex.wordpress.org/Function_Reference/wp_remote_post
}
add_action( 'publish_post', 'my_custom_post_action', 10, 2 );
You may need to ensure that the post is actually “new”, as this hook will be triggered any time a post’s status is changed to “publish”. The Action/Filter reference has a lot of other hooks you can use that are related to posts.
Related Posts:
- How to: Make JWT-authenticated requests to the WordPress API
- How would I add custom tables/endpoints to the WP REST API?
- WP REST API create post authentication issue
- Why is my custom API endpoint not working?
- WordPress REST API validation
- Are there server performance benefits to fetching only specific fields when querying the REST API?
- WordPress Rest API: How do we validate with our custom API key?
- Adding WordPress API Endpoint With Multiple Parameters
- Using the REST API (v2) javascript client on a private namespaced route
- authentication issue with rest api – rest_cannot_create
- Hiding API routes list
- Match REST API post output from custom endpoint
- How to change user avatar using REST API?
- rest api authentication
- Does accessing WordPress via REST API affect the site stats and analytics?
- x-wp-nonce is not allowed by Access-Control-Allow-Headers in preflight response
- How to get around WP REST API per page limit without pagination?
- Build on same WordPress or different install?
- Testing custom API endpoint with class dependency
- How to properly add custom entities in Gutenberg
- REST API custom endpoint without authentication for POST method?
- CORS & Remote access to WP via RestAPI
- Not all featured image sizes available in Rest API
- 403 Forbidden with gutenberg
- WordPress doesn’t send a notification email when submitting a comment using REST API
- Using WordPress RESTapi to call a php file instead of post or page
- Detect if REST API is running
- WordPress REST API – Modify JSON before importing
- Using pre_get_posts, how to target the REST API, only?
- Save/update post_meta with Gutenberg from the panel
- Set featured image using URL with wp rest api
- How to block all REST API endpoint except which I wrote custom?
- Authentication with internal WP_REST_Request and rest_do_request()
- pagination in WP rest api
- Can the new REST API now make WP into it’s own push notification server?
- Confused about AngularJS and WordPress
- Post API tax_relation field doesn’t work
- Cannot DIsplay a Snackbar Notice on Button Click – Notice is undefined
- How to post an unserialized array via wordpress rest API as meta data
- Use the backbone.js client to save custom post type meta
- Override WordPress POST REST API
- Custom Post Type and Custom REST API Endpoint result in Gutenberg editor not working
- rest_sanitize_value_from_schema doesn’t sanitize string
- Erratic OAuth 1.0 Signature Mismatch Errors
- Creating a custom endpoint for rest, I see the endpoint exists in the wp-json, but the request is returning 404
- WordPress + Vue — Single page app giving me 404s when I use query params
- WordPress Rest API custom endpoint for RSS feed
- How to add a custom REST field to limit data when fetching?
- Get subscribers via REST API and send post notification
- WordPress JSON data to and from database to be shown on rest point
- “No Access-Control-Allow-Origin header is present” even though it is in the entry file
- How to Get Featured Image from REST API?
- Allow “wp-admin” edit access through headless WP web application
- Is it Ok to restrict Access-Control-Allow-Origin for /wp-json requests?
- Error invalid parameters with REST API
- How to get featured image in WP rest api
- rest api endpoint – accept diacritic characters
- WordPress REST API rest_comment_invalid_author Sorry, you are not allowed to edit ‘author’ for comments
- How to send the body in wp_remote_post as “raw”?
- Accessing private posts through REST API, same code that works in remote doesn’t in local
- REST API and filtering by meta value
- Custom Endpoints not working
- Is there a way I can fetch the WordPress Developer Code References with an API?
- `WP_REST_Controller::get_endpoint_args_for_item_schema` Does Not Set `required` Property from Schema
- Pull in ALL posts from the last two weeks using Rest API
- Extending REST API responses
- 403 error when publishing a post in wordpress. Error => Publishing failed. The response is not a valid JSON response
- Cannot use WordPress Application Passwords: “code”: “rest_no_route” “status”:404 for /wp-json/wp/v2/users/me/application-passwords
- How to add Relations of a CCT from JetEngine via WordPress Rest API
- Pass multiple tags slug to rest API
- Return a WP_REST_Response from an inner function (and not from the root callback)
- wp_nonce vs jwt
- Rest Api fetching only one random post
- WP REST API returns empty posts despite entries in wp_posts
- Accessing Custom REST endpoint with rest_do_request()
- How to add taxonomy to a post using WP REST API?
- WP CLI in WP 5.3 with PHP 7.4
- The REST API encountered an error in wordpress?
- Get wordpress post with featured image, category and tag from WordPress API
- Do something when publish a post in Gutenberg with hook rest_after_insert_post
- Uploading picture via REST API
- How to modify the HTML output of Gutenberg block? (Youtube)
- Extract XML/JSON element from Zillow API response and populate into Gravity Forms field
- Can I use REST API if the site is protected with .htpasswd
- WordPress single page website redirect to index.html
- How to get the most recently updated orders via the REST API?
- Fetching all users that didn’t post with rest api (current version 2)
- Calling a python script from custom wordpress rest api returns null
- Autotrader API Integration
- Accessing secure endpoint with X-WP-Nonce?
- Return all custom taxonomy terms for post in REST API v2? Currently limited to 10 terms
- WP Rest API V2 OR Operator in URL
- how can I add an URL parameter to a rest route using register_rest_route()?
- Call to undefined function upload_is_user_over_quota()
- Rest api request throttling
- How can I set the default ‘orderby’ and ‘order’ parameters for a REST API call?
- What filtering is available for backbone.js?
- How to limit what fields are returned through the WP API Backbone JS client
- Woocommerce API for calling products by Category ID
- wordpress rest api authentication failed