WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to do check the inserted post for certain keywords and perform some functions depending on the keywords found.

is there a wordpress hook that executes "just before the post is inserted into the database" ? Or will i have to modify wordpress core ?

Also, i will need to prevent the post from being inserted into the database if some keywords are found. is this something that can be done with a hook ? Or will a core modification be needed ?

share|improve this question

Available actions:

  1. pre_post_update - Runs just before a post or page is updated.
  2. publish_post - Runs when a post is published, or if it is edited and its status is "published".
  3. save_post - Runs whenever a post or page is created or updated, which could be from an import, post/page edit form, xmlrpc, or post by email.
  4. wp_insert_post - Same as save_post, runs immediately afterwards.

More info: Plugin API/Action Reference


add_action('action_name', 'callback_name');
share|improve this answer
None of these happen before the post is inserted into the database – Bainternet Mar 15 '11 at 1:34

The hook is save_post:

add_action('save_post', 'dosomething'), 10, 2);

share|improve this answer

the hook is wp_insert_post_data

which as two parameters ($data, $postarr) and its a filter hook that fires before inserting the post into the database so:


as for save_post hook it happens after inserting the post to database.

share|improve this answer
Thanks for your help. Can i stop the post from being saved in the database using this hook ? How ? – WarDoGG Mar 15 '11 at 3:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.