Group Mods

  • Profile picture of @mercime
  • Profile picture of r-a-y
  • Profile picture of Hugo

display username in members directory (15 posts)

Started 2 years, 2 months ago by: intimez

  • Profile picture of intimez intimez said 2 years, 2 months ago:

    I’m trying to display the sign up username in the directory but it’s showing empty space instead

    Here’s part of the code:

    <div class="item-title">
    <a href="<?php bp_member_permalink() ?>"><?php bp_displayed_user_username() ?></a>
    <?php if ( bp_get_member_latest_update() ) : ?>
    <span class="update"> - <?php bp_member_latest_update( 'length=10' ) ?></span>
    <?php endif; ?>
    </div>

    Can someone let me know what I did wrong?

    [wordpress2.9.2+buddypress1.2.1]

  • Profile picture of r-a-y r-a-y said 2 years, 2 months ago:

    No need to edit a template file for this.

    Try adding the following in your theme’s functions.php:

    function my_member_username() {
    	global $members_template;
    
    	return $members_template->member->user_login;
    }
    add_filter('bp_member_name','my_member_username');
  • Profile picture of intimez intimez said 2 years, 2 months ago:

    I placed it in “plugins” and it works great! It’s a slow process but I’m learning from these snippets.

    Is there a reference guide where you pulled these from for those of us not as verse with the different variables used?

    I’ll try to get the same result for the comment section to match the name used in the members directory.

    Thank you so much!

  • Profile picture of r-a-y r-a-y said 2 years, 2 months ago:

    Yes, it’s called manually going through the code ;)

    Try looking through the various bp-COMPONENT-templatetags.php files.

    There’s also the codex – codex.buddypress.org – but it needs a little TLC.

  • Profile picture of angelpix Angelpix said 2 years, 1 month ago:

    In reference to:

    No need to edit a template file for this. Try adding the following in your theme’s functions.php:

    function my_member_username() {
    global $members_template;

    return $members_template->member->user_login;
    }
    add_filter(‘bp_member_name’,'my_member_username’);

    I don’t want to mess anything up… There are 67 lines of code, in what area of the theme’s functions.php code do I paste the above mentioned code into

  • Profile picture of r-a-y r-a-y said 2 years, 1 month ago:

    Anywhere. Top, bottom, wherever.

    It’s always good to organize items in your theme’s functions.php.

  • Snap. That code crashed my site. I just want it so people’s full names aren’t showing up here:

    http://oneword.com/activity

    Thanks!

  • Profile picture of Paul Gibbs Paul Gibbs said 2 years ago:

    “Crashed” your site, how? White page? Probably you made an error putting the code into functions.php.

  • Yes. White page. Error putting the code in? Obviously.

  • Haha. Okay, apparently the problem is that I already had it in there… :) So it works great in the members directory, now how can I extend that to the activity feed? Thanks.

  • Profile picture of cpkid2 cpkid2 said 2 years ago:

    I’d like to know how to extend it to the activity feed as well as bbPress. I have bbPress integrated with Wordpress and the users’ first names are appearing instead of their usernames.

  • Profile picture of lenasterg lenasterg said 1 year, 9 months ago:

    If you want to display both usernames and display names you can use this version in your theme’s functions.php:

    /*Display Username and display name in Directory */
    function my_member_username() {
    global $members_template;
    if ( empty($members_template->member->fullname) ) {
    $members_template->member->fullname = $members_template->member->display_name;
    }
    $toReturn =$members_template->member->fullname .’ @’.$members_template->member->user_login;
    return $toReturn;
    }
    add_filter( ‘my_member_username’, ‘wp_filter_kses’ );
    add_filter( ‘my_member_username’, ‘stripslashes’ );
    add_filter( ‘my_member_username’, ‘strip_tags’ );

    add_filter(‘bp_member_name’,'my_member_username’);

  • Profile picture of notpoppy notpoppy said 8 months, 3 weeks ago:

    Can this code be adapted to show BOTH the Display Name and the Username together next to comments left on the main blog?

    This is so that people can see both the regular Display Name of whoever has left a comment, but also the user name so they can add an @ message addressed in the correct way.

    This is related to a query I posted here:

    http://wordpress.org/support/topic/show-display-name-and-username-in-comments?replies=1#post-2320564

  • Profile picture of notpoppy notpoppy said 7 months, 1 week ago:

    The solution from @lenasterg works very well in the members directory and search results, but I would still like to be able to do the same on the comments for the main blog as well.

    I’ve been trying to write a hook for functions.php to do this but I’m getting nowhere. Any help would be appreciated.

  • Profile picture of notpoppy notpoppy said 7 months ago:

    A further question on the solution from @lenasterg:

    Is it possible to add another filter which changes any spaces in usernames into hyphens?

    I have some users who signed up before spaces in usernames were automatically turned into hyphens, so I need it to display @mr-smith instead of @mr smith.