Skip to:
Content
Pages
Categories
Search
Top
Bottom

Only show usernames


  • 2bak860
    Participant

    @2bak860

    Hi,

    I’m trying to get buddypress to just show usernames, not real names.

    I know the code for fullnames:

    <?php bp_user_fullname() ?>

    But what is the tag for just the username?

    thanks!

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

  • John James Jacoby
    Keymaster

    @johnjamesjacoby

    There’s a few ways to do this, and it depends on where you are in the site and what information you might already have available, and if you want the current user, or a user in a loop of some kind.

    If by username you mean their user_login name, sometimes you can just do…

    bp_core_get_username($user_id);

    …where $user_id is the ID of the user you’re looking for.

    Let me know if this doesn’t work in your situation?


    2bak860
    Participant

    @2bak860

    Hi John, thanks for your reply – yes, I mean user_login.

    I’m editing the profile-header.php in bpmember. I’ve added your code, but now no username displays:

    <div id="profile-name">
    <h1 class="fn"><a href="<?php bp_user_link() ?>"><?php bp_core_get_username($user_id); ?></a></h1>

    <?php if( function_exists('bp_user_status') ) : ?>
    <p class="status"><?php bp_user_status() ?></p>
    <?php endif; ?>
    </div>

    Any help appreciated!


    Jeff Sayre
    Participant

    @jeffsayre

    Try this instead:

    <h1 class="fn"><a href="<?php bp_user_link() ?>">
    <?php echo bp_core_get_username(bp_displayed_user_id()); ?></a></h1>


    2bak860
    Participant

    @2bak860

    Lifesaver – thank you Jeff!


    2bak860
    Participant

    @2bak860

    Is there a way to remove the “Name” from the Profile page? Name is the label, but I can’t change the value to the username.

    Any ideas?


    2bak860
    Participant

    @2bak860

    I know it’s a core field, but is there anyway not to display it?


    2bak860
    Participant

    @2bak860

    Just on the profile page?


    r-a-y
    Keymaster

    @r-a-y

    If you want to hide the core xprofile “name” field, you’ll have to edit the /profile/profile-loop.php file in order to do this.

    One way to do this is mentioned here:

    https://buddypress.org/forums/topic/faq-how-to-code-snippets-and-solutions#post-13243

    This will hide your entire “Base” xprofile group though.

    But that’s one way around it!


    2bak860
    Participant

    @2bak860

    Thanks r-a-y – I’ll give that a shot!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Only show usernames’ is closed to new replies.
Skip to toolbar