Skip to:
Content
Pages
Categories
Search
Top
Bottom

bp_displayed_user_username or another?


  • takuya
    Participant

    @takuya

    I’d like to use the function, “bp_displayed_user_username” not only member-header.php but also on member-loop.php, but this function so far only works on member-header.php

    If you know how to make this work, please advise.

    If there’s another function that does the same, please let me know.

    I’m looking at bp global reference, but have no idea how I can customize the example code, so that this function works.

    http://codex.buddypress.org/developer-docs/the-bp-global/

    I’m trying to use this function on the following of member-loop.php

    <div class="item-avatar"><br /><img src="http://img.tweetimag.es/i/<?php bp_displayed_user_username() ?>_b" /></a><br /></div>

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

  • Brajesh Singh
    Participant

    @sbrajesh

    You are right, It will work on members page only, as it uses $bp->displayed_user which is set for member pages only.

    You can accomplish the same by using function

    “bp_core_get_username” on any of the pages. take a look at the function definition.


    takuya
    Participant

    @takuya

    Thanks for the suggestion, however “bp_core_get_username” doesn’t yet return (display) anything. I wonder if there’s anything changed from version 1.2


    takuya
    Participant

    @takuya

    I think this “bp_core_get_username” is used only for one member. This doesn’t work on members-loop.php where it should list member names and avatars on the Members Directory.

    The function should be something equivalent to

    <?php bp_member_name() ?>

    But instead of member nickname it should return login ids of members.

    I just found the following custom function, but I wonder why this function is not built in by default.

    https://buddypress.org/forums/topic/display-username-in-members-directory#post-41928


    takuya
    Participant

    @takuya

    Does anyone know how I can modify this code into a new function, rather than overwriting bp_member_name? I’ve tried add_function instead, but didn’t work. Preferably I’d like to create a new function called bp_member_username.

    function my_member_username() {

    global $members_template;

    return $members_template->member->user_login;

    }

    add_filter('bp_member_name','my_member_username');


    Boone Gorges
    Keymaster

    @boonebgorges

    If using bp_core_get_username, make sure you do the following:

    – echo the result. Unlike bp_displayed_user_username(), it does not echo automatically. Ie

    <?php echo bp_core_get_username( $user_id ); ?>

    – Feed it $user_id as an argument. If you don’t, the argument will return false.

    See bp-core.php, around line 1005, for the definition of the function, as Brajesh suggested.


    takuya
    Participant

    @takuya

    To my understanding and testing experience, the following doesn’t return list of usernames of members on members-loop.php

    <?php echo bp_core_get_username( $user_id ); ?>


    takuya
    Participant

    @takuya

    Solved this, answer is here for anyone with the same problem.

    https://buddypress.org/forums/topic/displaying-usernames-on-members-directory-part-2

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘bp_displayed_user_username or another?’ is closed to new replies.
Skip to toolbar