How to insert custom function into wp_insert_post

See those two hooks in the hacked Core code you posted?

do_action('save_post', $post_ID, $post);
do_action('wp_insert_post', $post_ID, $post);

Those are what you need to use to do this right.

function run_on_update_post($post_ID, $post) {
    var_dump($post_ID, $post); // debug
    include '../push/send_message.php';
    sendNotification($post['post_title'],$post['guid']);
    return $post_ID;

}
add_action('save_post', 'run_on_update_post', 1, 2);

save_post runs every time the post is saved. I can’t swear that your function will work but you should be able to modify things to make it work. Just look at the var_dump and alter accordingly. The includes may not work either, as they are relative paths. You may have to change that as well.

Leave a Comment