Saturday, October 15, 2022
HomeWordPress Developmentwp distant submit - Webhook: save_post motion fires wp_remote_post twice

wp distant submit – Webhook: save_post motion fires wp_remote_post twice


I’m attempting to implement a webhook in a plugin which ought to fireplace everytime a consumer saves a submit. It really works wonderful, however I recive two requests on frontend api. The primary request has acquired a incorrect slug. I’m wondering why that is taking place or what I’m doing incorrect right here. The second name works good.

 outlined('ABSPATH') or die('Unauthorized entry');

 add_action('save_post', 'update_front_end', 10, 2);
 operate update_front_end($post_id, $submit){

   $exovias_webhooks_options = get_option( 'exovias_webhooks_option_name' ); // Array of All Choices
   $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);

}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments