0
votes

When I publish a post on WordPress from ADMIN area, the hook "wp_insert_post" works fine:

function testing( $post_id, $post, $update ) {
    error_log('testing');
}
add_action('wp_insert_post', 'testing', 10, 3);

But when I publish from PUBLIC area (and there are no errors here), even using wp_insert_post to publish the post, the function above isn't called.

Why does it happen? And is it possible to solve that?

1
What plug-in you use to let people post from the front-end? Or do you use your own code?berend
AccessPress Anonymous Post. Why?Marcel
Do you know a better plugin, Berend?Marcel
I always use gravity forms, but your plug-in also works.berend

1 Answers

1
votes

Okay, I downloaded your plug-in and tested it and for me it works just fine. You should know though that WordPress already inserts the post when you request the page, not after you press submit/save. Anyway here is what I posted in the frontend:

frontend

I added a breakpoint in your function and it gets there just fine:

phpstorm

So the problem must be elsewhere, are you sure you are checking the error_log in the right place?