WordPress offers some pretty neat administrative features right out of the box. One such bit of functionality is the user contact information block. This section is located in users profile and allows them to set a number of pre-defined user contact fields.
Defining custom user contact fields in WordPress allows your site’s visitors to connect with other users and team members on more platforms. However, there are no built-in options to add custom user contact fields in the back-end. With this in mind, we’ve put together this custom user contact methods tool to help savvy WordPress developers create a friendlier back-end for clients.
But before we introduce this code snippet generator tool and explain how you can use it, let’s take a closer look at what user contact methods in WordPress are.
What Are User Contact Methods in WordPress?
If you’ve ever added or edited a user in the WordPress back-end, then you’re probably already familiar with the contact fields that are available by default. Typically, these fields will be Email and Website.
With a little coding, you can customize the contact information fields that are available to your site’s users. For instance, if you’d rather have your users add their Twitter handles or links to their Google+ pages then you can add custom user contact methods for Twitter and Google+. This makes it easier for your site’s viewership to connect with users on social networks of your choosing.
How Do I Use This Custom User Contact Methods Snippet Generator Tool?
We’ve designed this code snippet generator tool to help both WordPress developers and first-time theme builders add custom user contact methods to their theme’s back-end. This tool allows you to add up to six more custom user contact fields at a time. All you have to do is enter the required fields and the tool will output a custom code snippet for you.
Let’s take a look at the individual fields one by one:
- Theme Slug: Enter your theme’s slug into this text field in all lowercase letters, numbers and/or underscores. This value will be used to prefix functions and variables that would otherwise be incompatible with the WordPress core or any installed themes or plugins. Typically, this is the same string as the text domain, with underscores in place of hyphens.
- Text Domain: The text domain works as a unique key that will be used to identify any translatable strings in your theme or plugin. It should be the same as your theme’s name in lowercase with spaces replaced by hyphens – in other words, it should match the theme’s directory name in the root folder.
Method #N Tab
- Method #N Key: Enter the user contact method’s key. It should be a unique identifier that points to the contact method’s array containing the method description. This field accepts a string ID in all lowercase letters and hyphens (no spaces).
- Method #N Description: Enter a custom, descriptive summary for the custom user contact method in this field such as custom-description, Twitter handle.
- Once you’ve enabled all of the options you’d like, navigate to the Code tab. You’ll find that the Register User Contact Methods text area is populated with a custom code snippet for adding custom user contact methods to your WordPress site.
How Do I Add the Code Snippet to My Website?
One way to add the generated code snippet to your site is by pasting it directly into your current theme’s functions.php file. To do this, head over to Appearance > Editor from the admin panel, open the functions.php file, and paste the code directly into it. The function should not be called before the init action.
Alternatively, you can download the theme’s functions.php file to your desktop via an FTP client. Next, open it up in a text editor, and paste the code at the bottom of the file. Once you’re done, click the Save button and re-upload it to your theme’s directory. The custom user contact methods will then be available for use.
We designed this tool to make it easier for WordPress developers to add customized user contact information fields into their WordPress themes. Hopefully, this code snippet generator tool will save you some time and effort from having to write code by hand. We encourage you to give it a try in your next theme development project.
Do you have any questions about this Custom User Contact Methods code generator tool? Which custom user contact methods did you create with this tool? Let us know in the comments section below!