Forum Replies Created

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • in reply to: Using Display Name instead of @username? #50119
     stevejenkins
    Participant

    🙂

    in reply to: Using Display Name instead of @username? #50081
     stevejenkins
    Participant

    Can’t figure out how to modify my post, but if it wasn’t clear, you should only modify the child theme version of the member-header.php file.

    in reply to: Using Display Name instead of @username? #50080
     stevejenkins
    Participant

    It was SLIGHTLY more complex than that, Sharmstr. 🙂

    First, keep in mind that my site is subscription only and for a private non-profit association with a couple thousand members, so we don’t have problems exposing personal info to each other. Your standard user isn’t going to want their email address exposed to the world.

    First, I’ve added these functions to my functions.php:

    COPY CODE
    // Put Profile User's Email Address in Profile Header
    function DisplayedUserEmail() {
    global $bp;
    echo '<br /><div class="bp_header_email"><a href="mailto:'. $bp->displayed_user->userdata->user_email .'" target="_blank">'. $bp->displayed_user->userdata->user_email .'</a></div>';
    }
    
    //add_action( 'bp_before_member_header_meta', 'DisplayedUserEmail' );
    
    // Put Profile User's Display Name at top of profile
    function DisplayedUserFullName() {
    global $bp;
    
    echo '<h2 class="user-nicenmame bp_header_displayname">'. $bp->displayed_user->fullname. '</h2>';
    }
    add_action( 'bp_before_member_header', 'DisplayedUserFullName' );
    

    Then you can apply your own custom CSS to the bp_header_email and bp_header_displayname classes.

    Next, copy

    /wp-content/themes/kleo/buddypress/members/single/member-header.php

    to

    /wp-content/themes/kleo-child/buddypress/members/single/member-header.php

    This will allow the child theme version of the file to override.

    Then edit the member-header.php file so it contains what you want. For those who like diff, here are the differences between the original and my edits:

    COPY CODE
    # diff /www/vhosts/example.com/htdocs/wp-content/themes/kleo-child/buddypress/members/single/member-header.php /www/vhosts/example.com/htdocs/wp-content/themes/kleo/buddypress/members/single/member-header.php
    24,25d23
    < <div>
    < <h4 class="user-nicename"><?php echo xprofile_get_field_data('31'); ?><br>
    27,36c25,29
    < <?php
    < global $bp;
    < echo '<a href="mailto:'. $bp->displayed_user->userdata->user_email .'" target="_blank">'.$bp->displayed_user->userdata->user_email .'</a>'; ?>
    < </h4>
    < </div>
    <
    < <span class="activity">
    < <?php if ( bp_is_active( 'activity' ) && bp_activity_do_mentions() ) : ?>
    <       @<?php bp_displayed_user_mentionname(); ?>: <?php bp_last_activity( bp_displayed_user_id() ); ?></span>
    < <?php endif; ?>
    ---
    >       <?php if ( bp_is_active( 'activity' ) && bp_activity_do_mentions() ) : ?>
    >               <h4 class="user-nicename">@<?php bp_displayed_user_mentionname(); ?></h4>
    >       <?php endif; ?>
    >
    >       <span class="activity"><?php bp_last_activity( bp_displayed_user_id() ); ?></span>
    

    My entire member-header.php (in its edited state) looks like this:

    COPY CODE
    <?php
    
    /**
     * BuddyPress - Users Header
     *
     * @package BuddyPress
     * @subpackage bp-legacy
     */
    
    ?>
    
    <?php do_action( 'bp_before_member_header' ); ?>
    
    <div id="item-header-avatar" class="rounded">
            <a href="<?php bp_displayed_user_link(); ?>">
    
                    <?php bp_displayed_user_avatar( 'type=full' ); ?>
    
            </a>
      <?php do_action('bp_member_online_status', bp_displayed_user_id()); ?>
    </div><!-- #item-header-avatar -->
    
    <div id="item-header-content" <?php if (isset($_COOKIE['bp-profile-header']) && $_COOKIE['bp-profile-header'] == 'small') {echo 'style="display:none;"';} ?>>
    <div>
    <h4 class="user-nicename"><?php echo xprofile_get_field_data('31'); ?><br>
    
    <?php
    global $bp;
    echo '<a href="mailto:'. $bp->displayed_user->userdata->user_email .'" target="_blank">'.$bp->displayed_user->userdata->user_email .'</a>'; ?>
    </h4>
    </div>
    
    <span class="activity">
    <?php if ( bp_is_active( 'activity' ) && bp_activity_do_mentions() ) : ?>
            @<?php bp_displayed_user_mentionname(); ?>: <?php bp_last_activity( bp_displayed_user_id() ); ?></span>
    <?php endif; ?>
    
            <?php do_action( 'bp_before_member_header_meta' ); ?>
    
            <div id="item-meta">
    
                    <?php if ( bp_is_active( 'activity' ) ) : ?>
    
                            <div id="latest-update">
    
                                    <?php bp_activity_latest_update( bp_displayed_user_id() ); ?>
    
                            </div>
    
                    <?php endif; ?>
    
                    <div id="item-buttons">
    
                            <?php do_action( 'bp_member_header_actions' ); ?>
    
                    </div><!-- #item-buttons -->
    
                    <?php
                    /***
                     * If you'd like to show specific profile fields here use:
                     * bp_member_profile_data( 'field=About Me' ); -- Pass the name of the field
                     */
                     do_action( 'bp_profile_header_meta' );
    
                     ?>
    
            </div><!-- #item-meta -->
    
    </div><!-- #item-header-content -->
    
    <?php do_action( 'bp_after_member_header' ); ?>
    
    <?php do_action( 'template_notices' ); ?>
    in reply to: Using Display Name instead of @username? #49685
     stevejenkins
    Participant

    Got it figured out — put a copy of member-header.php in my child theme folder and went to town! 🙂

     stevejenkins
    Participant

    Got it fixed. Still don’t know what the problem was regarding the .zip install, but as for the problem with the FTP uploaded files… I was (DOH!) uploading it to an outdated directory location for the site and had forgotten that I’d moved the webroot in httpd.conf. THAT’S what happens when you mess with this stuff late on a Sunday night. 🙂

    Theme installed and looking pretty darn good.

Viewing 5 posts - 1 through 5 (of 5 total)

Log in with your credentials

Forgot your details?