Adding Functionality to Profile Filters
WordPress provides four contact methods by default: AIM, Yahoo! IM, and Jabber/Google Talk. These are, of course, extensible, meaning that you can easily add new contact methods through the use of filters. It's painless to add more, and you can even add on a little extra functionality while you're at it.
Users fill out their profile data in the WordPress Dashboard by going to UsersYour Profile (see Book III, Chapter 1). User profile fields are stored in the WordPress database in the user_metadata table and you can easily fetch them by using get_the_author_meta(‘aim’) and print them with the_author_meta(‘aim’). If you add a Twitter Contact Info field, it appears in profiles, and you can use the_author_meta(‘twitter’) template tags in your theme to print the account name.
Figure 7-9 shows the Twitter Contact Info field in a profile within the WordPress Dashboard.
the_author_meta() template tag has a hook called the_author_{$field}, where the PHP variable ‘$field’ is the requested meta field assigned to each contact type in the user profile files, such as ‘aim’ in the above example. These dynamic hooks are powerful because they allow you to narrow your target.
In this example, ...
Get WordPress® All-in-One For Dummies® now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.