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…
…where $user_id is the ID of the user you’re looking for.
Let me know if this doesn’t work in your situation?
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:
<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; ?>
Any help appreciated!
Try this instead:
<h1 class="fn"><a href="<?php bp_user_link() ?>">
<?php echo bp_core_get_username(bp_displayed_user_id()); ?></a></h1>
Lifesaver – thank you Jeff!
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.
I know it’s a core field, but is there anyway not to display it?
Just on the profile page?
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:
This will hide your entire “Base” xprofile group though.
But that’s one way around it!
Thanks r-a-y – I’ll give that a shot!