Every time I use saving button from post editor in wordpress, my browser asks me if I want to leave the page.
I have a few plugins installed, I'm developing a new one. It never happened to me before working on wordpress.
I'm using wp_insert_post
hook to do some things every time I save post/page.
EDIT 1
Every time I update a single post, browser shows me an alert telling me If I want to leave the page. I discovered, that the plugin that cause this alert to show it's YOAST.
Can you please give a hand, and tell me what do I have to do to solve this problem?
Thanks,
Ismael
in order to do something every time you publish or update a post in wordpress you have to use save_post:
for example if you want to send an email every time a post or page is updated on your website.
function my_project_updated_send_email( $post_id ) {
// If this is just a revision, don't send the email.
if ( wp_is_post_revision( $post_id ) )
return;
$post_title = get_the_title( $post_id );
$post_url = get_permalink( $post_id );
$subject = 'A post has been updated';
$message = "A post has been updated on your website:
";
$message .= $post_title . ": " . $post_url;
// Send email to admin.
wp_mail( 'admin@example.com', $subject, $message );
}
add_action( 'save_post', 'my_project_updated_send_email' );