Skip to:
Content
Pages
Categories
Search
Top
Bottom

Ho to style a $field_data in buddypress function


  • imborx
    Participant

    @imborx

    Hi, I would like to set a css class/style (in this case “font-weight: 400;”) to a $field_data in a buddypress function and I’m not really sure how can I do that. This is the code:

    function yzc_add_xprofile_field_data_after_username( $name ) {
        if ( bp_is_members_directory() ) {
    
            $field_data = xprofile_get_field_data( 'Age', bp_get_member_user_id() );
            return $name . ', ' . $field_data;
        }
        return $name;
    }
    add_filter( 'bp_member_name', 'yzc_add_xprofile_field_data_after_username', 10 );

    Image with code selected

    Thanks a lot!

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

  • Venutius
    Moderator

    @venutius

    Hi there,

    If I was looking to do this I’d overload members/members-loop.php and add the styling there. bp_member_name only returns the name of the member, not an element that you can style. In the members-loop it’s used to create a link to the members profile and you could either apply the styling to that.

    An alternative would be to simply add this as css styling such as:

    .member-name {
        font-weight: 400;
    }

    imborx
    Participant

    @imborx

    Thank you so much! That really helps

    Cheers!

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar