Custom Profile Filters for Buddypress

Out of the box, BuddyPress automatically turns some words and phrases in the fields of a user’s profile into links that, when clicked, search the user’s community for other profiles containing those phrases. When activated, this plugin allows users and administrators to have more control over these links, in the following ways:

1) By using square brackets in a profile field, users can specify which words or phrases in their profile turn into links. For example: under Interests, I might list “Cartoons about dogs”. By default, Buddypress will turn the entire phrase into a link that searches the community for others who like cartoons about dogs. If I instead type “[Cartoons] about [dogs]”, then the two words in brackets will turn into independent links.

2) Administrators can specify certain profile fields that will not turn into links at all. The standard setting for the plugin is that fields labeled ‘Phone’, ‘IM’, and ‘Skype ID’ will not become linkable (it doesn’t make much sense to search a community for what should be a unique handle, after all). See custom-profile-filters-for-buddypress.php to configure this setting.

3) Administrators can specify certain profile fields that link to social networking profiles. If I enter my Twitter handle ‘boonebgorges’ into a field labeled ‘Twitter’, for example, this plugin will bypass the default link to a BuddyPress search on ‘boonebgorges’ and instead link to See custom-profile-filters-for-buddypress.php to configure this setting.

Download the plugin here.

Custom Profile Filters for BuddyPress has been downloaded [downloadstat url=”” get=”total” autop=”false”] times. Are you using this plugin? Consider a donation.

Some previous blog posts about this plugin:


Version history

Initial release
Added automatic linking for various social networking sites
0.3 – February 27, 2010
Conforms to BP 1.2 standards for loading order
Most functionality moved to proper filters in order to inherit BP native code
0.3.1 – March 2, 2010
Moved globals back to main plugin file
Fixed error regarding missing function arguments (thanks for reporting them, Mike!)

12 thoughts on “Custom Profile Filters for Buddypress

  1. Kiwipearls

    I like this plugin. I am just wondering how I can edit it to do what I need also.

    I have a gaming site and I want users to list their characters and the realm they play on.

    I want to link to the WoW Armoury but character links have the realm in it.

    ie ‘Character’ => ‘***’,

    How can I get your plugin to insert the realm name into the url from a field in my profile.

    I am not clever enough to code this.

    I look forward to hearing from you. You can email me directly on the email provided.

  2. Boone Gorges Post author

    kiwipearls – Sounds like you’ve already got it figured out. Add a comma after line 26 of custom-profile-filters-for-buddypress.php and add your line. The two lines together should read like this:

    'FriendFeed ID' => '***',
    'Character' => '***'

    I’ve tested it on my installation and it works perfectly.

  3. Kiwipearls

    Thanks for your reply.

    Oh yeah, it does work perfectly if you already have the realm my toons are on Ghostlands…so I need to put that in url.

    ‘Character’ => ‘***’

    But other members of my site have characters on different realms.

    So I need a way to gather their realm info – which in their profile I have a realm field. But need to insert that realm field where word Realm is..***’

    ‘Character’ => ‘***’

    I just don’t know how to get your plugin to get that data. I am not good at coding.

  4. Boone Gorges Post author

    Saying “I’m not good enough to code this” over and over again does not make me more sympathetic!

    Anyway, if you don’t have a bp-custom.php file in your plugins directory yet, create one (making sure to have <?php at the very beginning of the file and ?> at the very end of it). Then put the following function in the file:

    function cpfb_add_double_links( $field_value ) {
    global $bp;
    $bp_this_field_name = bp_get_the_profile_field_name();

    if ( $bp_this_field_name == 'Character' ) {
    $url = str_replace( '***', strip_tags( $field_value ), '***' );
    $url = str_replace( '%%%', bp_get_profile_field_data( array( 'field' => 'Realm' ) ), $url );
    $field_value = '<a href="http://' . $url . '" rel="nofollow">' . $field_value . '</a>';

    return $field_value;
    add_filter( 'bp_get_the_profile_field_value', 'cpfb_add_double_links', 2, 1 );

  5. Kiwipearls

    Thanks so very much for that.

    I didn’t want you to be sympathetic. I am not a programmer. I just didn’t think that I explained my problem cleary enough. As your plugin works perfectly.

    Once again thanks for taking the time to write the code. I really appreciate that.

  6. APC

    Great plugin, super quick suggestion:

    It would be great to specify p and br as exceptions when you use the strip_tags function. That way linebreaks won’t be stripped from multi-line paragraph sections.

    So line 47 would read:
    $field_value = strip_tags($field_value, ”);

    Any chance you could incorporate this into the next version?

    Thanks so much.

  7. APC

    ok, my code didn’t post properly, but basically the br and p tags should be between the quotes at the end of the line.

  8. Scott Hendison

    We are using this plugin, and it’s been very helpful, however, for the actual member profile field, we’d prefer that a business is able to write normally AND drop in a real link if they want to.

    Right now, Buddypress is linking random phrases that happen to be followed by a comma – is that really “normal behavior” right? Using a comma makes a link – but only SOMEtimes?

    This plugin has been great, letting us stop the autolinking in other fields, but for the profile field, only option seems to be…

    1. Tell people to write without commas, or,

    2. Using your #2 at the top of the post, admins can disable ALL links (even real .html) from the main profile area.

    Do I understand this correctly? Sure seems dumb on the part of BP to include this… “feature”.

    1. Boone Gorges Post author

      Scott – The logic behind that code is that if someone puts a bunch of things with commas between them (apples, oranges, plums, pears), it’s probably a list, and if it’s a list, then the things on the list are probably interesting enough to link to a search.

      If you’re unhappy with the profile links throughout, try putting the following in your functions.php:

      remove_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_link_profile_data', 9, 2 );

      This assumes that you’re running a recent version of BP (1.5 or greater).

      If you want a solution that will let you delink fields more selectively, you could write a function that links early to ‘bp_get_the_profile_field_value’ and, by examining the $field global, selectively unhooks the filter in the way listed above.

Comments are closed.