Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/27/2009 08:01:21 PM (16 years ago)
Author:
apeatling
Message:

@username notifications and filters.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-filters.php

    r2168 r2218  
    5555}
    5656
     57function bp_activity_at_name_filter( $content ) {
     58    include_once( ABSPATH . WPINC . '/registration.php' );
     59
     60    $pattern = '/[@]+([A-Za-z0-9-_]+)/';
     61    preg_match_all( $pattern, $content, $usernames );
     62
     63    /* Make sure there's only one instance of each username */
     64    if ( !$usernames = array_unique( $usernames[1] ) )
     65        return $content;
     66
     67    foreach( (array)$usernames as $username ) {
     68        if ( !username_exists( $username ) )
     69            continue;
     70
     71        $content = str_replace( "@$username", "<a href='" . bp_core_get_user_domain( bp_core_get_userid( $username ) ) . "' rel='nofollow'>@$username</a>", $content );
     72    }
     73
     74    return $content;
     75}
     76add_filter( 'xprofile_activity_new_update_content', 'bp_activity_at_name_filter' );
     77add_filter( 'groups_activity_new_update_content', 'bp_activity_at_name_filter' );
    5778
    5879?>
Note: See TracChangeset for help on using the changeset viewer.