Skip to:
Content
Pages
Categories
Search
Top
Bottom

Add a CSS class to the activity posts display-name


  • Andrew
    Participant

    @sm60

    How do I filter the activity posts display-name so it has a CSS class?

    I’ve located the apply_filter line in buddypress/bp-members/bp-members-functions.php:

    return apply_filters( 'bp_core_get_userlink', '<a href="' . $url . '" title="' . $display_name . '">' . $display_name . '</a>', $user_id );

    and I want to change:
    '<a href="' . $url . '" title="' . $display_name . '">' . $display_name . '</a>'

    to:
    '<span class="display-name"><a href="' . $url . '" title="' . $display_name . '">' . $display_name . '</a></span>'

    Any help appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)

  • Henry Wright
    Moderator

    @henrywright

    Something like this:

    function sm60_filter( $html, $user_id ) {
        // Get the data we need.
        $display_name = bp_core_get_user_displayname( $user_id );
        $url = bp_core_get_user_domain( $user_id );
    
        // Now you can filter.
        $html = '<span class="display-name"><a href="' . $url . '" title="' . $display_name . '">' . $display_name . '</a></span>';
        return $html;
    }
    add_filter( 'bp_core_get_userlink', 'sm60_filter', 10, 2 );

    Andrew
    Participant

    @sm60

    It worked. Perfect. Thanks for your help 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Add a CSS class to the activity posts display-name’ is closed to new replies.
Skip to toolbar