Monthly Archives - August 2020

Player Profile Social Icons

In the version 3.16 update, we introduced the ability to filter social icons in player profiles. Social icons are the linkable icons that appear in the screenshot below:

Steam icon available after snippet.

By default, Tournamatch supports Facebook, Homepage, Twitch, Twitter, and YouTube. These social icon fields appear as configurable options to your users when he or she edits their player profile:

You may modify the social icons available to your users by adding extending Tournamatch 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 before.

A social icon in Tournamatch requires three fields: display_name, icon, and input_type. The display_name is the pretty name displayed to the user when editing his or her profile, the icon field is the name of the FontAwesome icon which will be displayed linkable in the public profile, and the input_type is text. You can look up any applicable social media icon on this page under the brand section.

In the screenshot below, the sample code adds the social media icons Instagram and Steam to the default list. Pay special attention to the function array_merge. Using this adds your icons to the list of defaults already given.

Custom Player Profile Social Icons Code

Add a filter for ‘trn_player_social_icon_fields’ to modify the social icons displayed to the user.

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.

How to Extend a Plugin with Code Snippets

How to Extend a Plugin with Code Snippets

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.

Steam icon available after snippet.

Steam icon available after snippet.