O'Reilly logo

WordPress® All-in-One For Dummies® by Michael Torbert, Andrea Rennick, Kevin Palmer, Cory Miller, Lisa Sabin-Wilson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 UsersimageYour 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.

Figure 7-9: Custom Twitter profile field, as shown in the Dashboard.

image

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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required