How do I display the user's First Name in BuddyPress?

This isn't actually about BuddyPress Group Calendar...but BuddyPress itself wasn't one of the options on the drop down.

So I know how to display a user's user name: bp_get_displayed_user_username

But what's the code to show FirstName LastName?

Thanks!!
Katy

  • katypurviance

    Hi David!

    Actually I'm in the BuddyPress Member Profile Stats plugin.

    It's default result is "[username] has been a member since [x] days ago."

    The plugin's author just wrote to me about how to change "since [x] days ago" to "since [date]". Once I get it working, I'll post it here to share with others who are looking for this.

    I found out the hard way that if you change "username" to "userrole" it makes all of your BuddyPress profile stuff magically disappear! Oopsies.

    Katy

  • katypurviance

    This is for everybody who wants to edit the BuddyPress Member Profile Stats plugin so that it will read "[username] has been a member since [date]" instead of "[username] has been a member since [x] days ago."

    #1. Open buddypress-member-profile-stats/bp-member-profile-stats.php in the Editor

    #2. Find where it reads:

    apply_filters( 'etivite_bp_member_profile_stats_get_member_registered', esc_attr( bp_core_time_since( $bp->displayed_user->userdata->user_registered ) ) );

    #3. Paste in this right underneath it:

    function etivite_filter_override_member_registered( $content ) {
        global $bp;
    
        return date( "F j, Y", strtotime( $bp->displayed_user->userdata->user_registered ) );
    }
    add_filter('etivite_bp_member_profile_stats_get_member_registered','etivite_filter_override_member_registered');

    The F j, Y is the code for The full name of the month, the day number, and the 4-digit year. You can customize this to your liking with the codes found here.

    I made a further modification. I didn't want it to read [username]. At first I thought I'd change it to FirstName Last Name (like my original question above), but then I decided that I just wanted it to read that they joined my site on that date. Here's what I did.

    I found where it reads:

    function etivite_bp_member_profile_stats_get_member_since() {
    		return '<div><em>'. bp_get_displayed_user_username() .'</em>'. __( ' has been a member for ', 'bp-member-profile-stats' ) .'<span class="member-since profile-count">'. etivite_bp_member_profile_stats_get_member_registered() .'.</span></div>';

    And I changed it to:

    function etivite_bp_member_profile_stats_get_member_since() {
    		return '<div>'. __( ' Joined ... on ', 'bp-member-profile-stats' ) .'<span class="member-since profile-count">'. etivite_bp_member_profile_stats_get_member_registered() .'.</span></div>';
    	}

    where ... is the name of my site.

    Hope this helps whoever is looking for this type of modification! :smiley:

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.