save_post hook fires many times on each update
-
Hi all,
I need to send a POST request every time a user creates/updates/deletes a page or a post.
Reading through the documentation I found that the ‘save_post’ hook seems to do exactly that.
The problem is that the call is fired many times and not just once (many like 13 times)
Is that an expected behaviour?
This is how i tried to implement it:
function trigger_build() { $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://address.example.com/hook-endpoint', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_HTTPHEADER => array( 'Authorization: Bearer SECRET_TOKEN' ), )); curl_exec($curl); } add_action('save_post', 'trigger_build')
Any advice?
Thanks
Matteo
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘save_post hook fires many times on each update’ is closed to new replies.