wp remote post – Webhook: save_post action fires wp_remote_post twice
Question
I am trying to implement a webhook in a plugin which should fire everytime a user saves a post. It works fine, but I recive two requests on frontend api. The first request has got a wrong slug. I wonder why this is happening or what I am doing wrong here. The second call works perfect.
defined('ABSPATH') or die('Unauthorized access');
add_action('save_post', 'update_front_end', 10, 2);
function update_front_end($post_id, $post){
$exovias_webhooks_options = get_option( 'exovias_webhooks_option_name' ); // Array of All Options
$secret_0 = $exovias_webhooks_options['secret_0']; // Secret
$frontendurl_1 = $exovias_webhooks_options['frontendurl_1']; // FrontendUrl
$slug = basename(get_permalink($post_id));
$url = $frontendurl_1 . '/api/revalidate?secret=" . $secret_0 ."&slug=' . $slug;
wp_remote_post($url);
}
0
1 year
2022-10-15T04:55:21-05:00
2022-10-15T04:55:21-05:00 0 Answers
0 views
0
Leave an answer