Skip to:
Content
Pages
Categories
Search
Top
Bottom

How do I refer to a member’s name in their profile?

  • @rgrober

    Participant

    Hello,

    I’m attempting to add information next to a member’s name in their profile and also in the member directory list.

    How do I refer to the member’s name (ex. bp_displayed_user_id)?

    For instance, referring to a member’s name in a profile: bp_(what goes here?)

    Here’s the little bit of code I’m trying to write for context:

    
    function user_badge(){
    	echo '<span class="adbadge">';
            echo 'AD';
            echo '</span>';
    }
    add_action ('display_name', 'user_badge');
    

    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • @danbp

    Participant

    See here:
    https://buddypress.org/support/topic/bp_field_has_data-show-message-when-empty-field/

    The snippet is checking for empty fileds. This is not what you want. Simply remove ! before $data, so it will check that if $data exist, do something. Exclamation point means “not”.

    Use add_filter( 'bp_before_member_header_meta filter', 'your_function_name' ); to add custom things to profile header and
    add_filter ( 'bp_directory_members_item', 'your_function_name' ); for members directory.

    @rgrober

    Participant

    @danbp for the saveā€¦again!

    I got this to work, but I wanted to know if there was a way for my message to display next to the user’s name? This places the message underneath everything.

    Is there something like ‘bp_after_member_name’?

    @danbp

    Participant

    Open the template file you want to modify and search for an action hook name.
    do_action ('something'). In your case, member-header.php whith perhaps bp_before_member_header_meta action.

    Usage:

    function xxx() {
    // do something
    }
    add_action( 'bp_before_member_header_meta', 'xxx' );
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How do I refer to a member’s name in their profile?’ is closed to new replies.
Skip to toolbar