How to Create a List of Forbidden Words for WordPress Titles

Watch out! This tutorial is over 4 years old. Please keep this in mind as some code snippets provided may no longer work or need modification to work on current systems.
Tutorial Difficulty Level    

If you manage a multi-author blog and want authors to avoid using certain words or phrases, then this will come in handy.  If an author has publishing rights, then the unwanted words can go live on your website. You can prevent this by taking away publishing privileges from users, but this means more work for you as you will have to review and publish posts yourself. So in this tutorial, we will show you how to create a list of forbidden words for WordPress titles.

Simply add the following code to your theme’s functions.php file like in previous tutorials, or use a site-specific plugin.

Don’t forget to add the words you want to ban in  the $restricted_words variable. You need to use a semicolon to separate different words and phrases.

This code simply triggers a function when a user tries to publish a post which checks the post title for restricted words. If it finds a restricted word in the post title, then it will show the user an error.