I have created a snippet that runs every time a seller updates their profile, which sends a webhook to a specific url. I have a problem because when a user updates their profile, this snippet launches twice. Does anyone know why?
It will not work this way, please name the callback function and remove it using its name, for example:
add_action('hook_name_here', 'my_custom_callback', 10, 2);
function my_custom_callback($vendor_id, $vendor) {
remove_action('hook_name_here', 'my_custom_callback', 10, 2);
// custom code here
}
Yes, this hook can be fired a few times during the request, for example if another vendor field is updated after other fields are updated, it also fires the same hook. By removing the callback you can make sure that your custom code runs once.