i'm trying to send push notification when the wordpress admin insert new post.
I was looking for hours where to add my function and after a lot i found core function wp_insert_post
inside wp-includes/post.php
that function returns the Post_ID, so i added my custom script before return:
include '../push/send_message.php';
sendNotification($postarr['post_title'],$postarr['guid']);
The problem is that when i import these two rows here
function wp_insert_post($postarr, $wp_error = false) {
...
if ( $update ) {
do_action('edit_post', $post_ID, $post);
$post_after = get_post($post_ID);
do_action( 'post_updated', $post_ID, $post_after, $post_before);
}
do_action('save_post', $post_ID, $post);
do_action('wp_insert_post', $post_ID, $post);
include '../push/send_message.php';
sendNotification($postarr['post_title'],$postarr['guid']);
return $post_ID;
}
nothing happen and when admin insert new post, the success page is blank. if i remove that line all is ok.. very strange.. Can someone give me a right way to do what i need?