Group Mods

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

Template tag for activity_username (10 posts)

Started 1 year, 8 months ago by: ch8rt

  • Profile picture of ch8rt ch8rt said 1 year, 8 months ago:

    I can’t find any documentation around the template tag for the username of the person that created an item in the activity stream.

    At the moment I’m stuck with the ID of that user, does anyone know the tag?

  • Profile picture of ch8rt ch8rt said 1 year, 8 months ago:

    Anyone?

  • Profile picture of Roger Coathup Roger Coathup said 1 year, 8 months ago:

    Pass the ID into bp_core_get_username

  • Profile picture of ch8rt ch8rt said 1 year, 8 months ago:

    Seems a bizzarre way around it? if I can use bp_activity_user_id() to get the id of the user that posted the item why isn’t there a ‘bp_activity_user_nicename()’ or something similar?

    Anyway, I’ll look into your suggestion on both this and the other topic you’ve replied to, thanks.

  • Profile picture of Roger Coathup Roger Coathup said 1 year, 8 months ago:

    Yes, it’s missing from the API. If you want it as a single function call, you can always write your own: my_activity_user_nicename() and put it in your bp-custom.php

    And, submit it to the trac as an API enhancement!

  • Profile picture of ch8rt ch8rt said 1 year, 8 months ago:

    I was hoping that <?php echo bp_core_get_username( bp_activity_user_id() ); ?> would fix it, apparently not, it just shows the ID number still.

  • Profile picture of Roger Coathup Roger Coathup said 1 year, 8 months ago:

    That surprises me… Post your full code sample, to show how you are calling it

  • Profile picture of ch8rt ch8rt said 1 year, 8 months ago:

    Well Its a bit messy, but I’m trying to re-engineer the meta part of the entry, so I’ll be using it in a few places like

    <a class="activity-avatar" title="<?php echo bp_core_get_username( bp_activity_user_id() ); ?>"
    href="<?php bp_activity_user_link() ?>" title="user name here">
    	<?php bp_activity_avatar( 'type=full&width=40&height=40' ) ?>
    </a>

    To add the username as a title on the Avatar, so it shows on mouseover. And

    <?php if ( bp_activity_has_content() ) : ?>
    	<a class="author" href="<?php bp_activity_user_link() ?>"><?php echo bp_core_get_username( bp_activity_user_id() ); ?> said: </a>
    	<?php bp_activity_content_body() ?>
    <?php endif; ?>

    As a prefix to the post content. Then I’m moving the rest of the meta data to the bottom of the post so I can drop the opacity of it since its less important.

  • Profile picture of Roger Coathup Roger Coathup said 1 year, 8 months ago:

    It’s not working because you are not passing an integer parameter for the user_id to bp_core_get_username()

    bp_activity_user_id() is a template tag for echoing a value to the screen, not for fetching a value to pass to a function.

    Instead use: <?php echo bp_core_get_username( bp_get_activity_user_id() ); ?>

  • Profile picture of ch8rt ch8rt said 1 year, 8 months ago:

    A massive help yet again. Thanks Roger for taking the time to answer these questions.