Your cart is currently empty!
How to Extend a Plugin in WordPress with a Filter Hook
Extending a plugin in WordPress may seem foreign if you have never done so; however, it is actually a simple task for most filter hooks. What is a filter hook? A filter hook is just the technical way of saying, “Here is some content we will display to the user or save to the database.” The most important thing to consider when writing your own filter hook is where you add this code. If you add this code in the wrong place, an update to WordPress or the plugin you are extending may overwrite your edit. You should strive to keep your website as up-to-date as possible, and having an update overwrite your changes generally discourages updates. Three safe ways to extend a plugin in WordPress with a filter hook include using another plugin such as Code Snippets, by creating a custom plugin, or by creating a child theme. I recommend going the first route which is detailed below.
Using a Filter Hook Plugin
The easiest way to extend a plugin is by using another plugin such as Code Snippets. This is the easiest method because it doesn’t require you to modify any code on the back end, use file transfer, or code editors. Code Snippets provides a simple GUI interface in your WordPress admin for managing action hooks, filter hooks, and custom shortcodes.
Using the player social icons filter we introduced in the Version 3.16 update as an example, here is how you would add a Steam icon to the existing set using Code Snippets:
1. Download and activate Code Snippets.
2. Paste the code into the box as pictured in the screenshot below.
3. Click save.
With this complete, players will now also see a steam icon in their player profile and a future WordPress or Tournamatch update shouldn’t affect your change.
3 responses to “How to Extend a Plugin in WordPress with a Filter Hook”
[…] with custom code which filters the default list. Filtering this list is easy, and you should read how to extend a plugin in WordPress if you have never done so […]
[…] In addition, you may also now filter the email messages Tournamatch sends to users and admins. A complete list of messages may be found here and steps to add a filter are here. […]
[…] supported. Here’s a sample snippet below using the Code Snippets plugin we reviewed in our How to Extend a Plugin in WordPress with a Filter Hook […]