I have a wordpress page. In that wordpress page, user will have access to the following Window to Publish their Post in to the webpage.

enter image description here

If the user enters an URL in any of the three filed I have marked in red above, my php code will look in to those URLs and determine if they are spam or not. Therefore, I want to put my php code inside the Publish button, so I can either disallow or allow the post after my php code run and determine if those URLs are spam or not.

Can you please tell me the name of the wordpress file I should edit in order to put my php code in. I am new to wordpress and don’t know too much about their file structure.

1 Answer 1


You should never ever modify WordPress Core files. WordPress has an Plugin API (http://codex.wordpress.org/Plugin_API) that allows you to modify WordPress to your liking without changing Core code.

In your case, the solution is to check the contents of the custom meta box fields before they are saved via the save_post action.

If the content is not valid, you can display a message on the post screen using the admin_notices action.

  • 1
    a link to some notes on what actions and filters are would be useful for new people
    – Tom J Nowell
    Apr 26, 2013 at 10:50
  • Agreed. I recommend this article as an introduction: wp.smashingmagazine.com/2012/02/16/…
    – Fränk
    Apr 26, 2013 at 10:52
  • @Fränk Please use - instead of comments - edits to your question. Thanks
    – kaiser
    Apr 26, 2013 at 10:59
  • @Fränk Thanks a lot for your help and the detailed information. I will be using filters. I have one last question, in the post.php file, $post_data['content'] shows the content of the text user entered in a post. Is there a variable similar to that which will show the URL for External Link (which is #2 in the image above)
    – Justin k
    Apr 26, 2013 at 12:16
  • @Justink To check the External Link (custom field), you should refer to its meta key (which you assigned to that field), e.g. $post_data['your_external_link_key']. So if you are having trouble locating the correct keys, you could inspect the variable via var_dump($post_data); or var_dump($_POST); and that will give you some more information as to what's being posted.
    – Adam
    Apr 26, 2013 at 13:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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