bbPress

Simple, Fast, Elegant

bbPress support forums » Requests and Feedback

search.php enhancement request

(10 posts)
  • Started 1 year ago by chrishajer
  • Latest reply from chrishajer

Tags:

  1. I've modified search.php a bit to make the results a little more readable (to my eye) and I was wondering how to get the poster name, to display with the results for recent posts and relevant posts.

    I would like to display something like:
    <a href="<?php post_link(); ?>"><?php topic_title($bb_post->topic_id); ?></a> <small><?php _e('Posted') ?> <?php echo date(__('F j, Y, h:i A'), bb_get_p
    ost_time()); ?></small> [BY MEMBER]

    the [BY MEMBER] part, to get the name of the member who made the post that is listed is the part I need help with. Thank you.

    Posted 1 year ago #
  2. You should be able to do this:

    get_user_name($bb_post->poster_id)

    Tell me if that doesn't work.

    Posted 1 year ago #
  3. That does not work :)

    Here is the code I am using:
    <?php foreach ( $recent as $bb_post ) : ?>
    <li><a href="<?php post_link(); ?>"><?php topic_title($bb_post->topic_id); ?></a><small> <?php _e('Posted') ?> <?php echo date(__('F j, Y, h:i A'), bb_get_post_time()); ?><?php _e(' by ')?><?php get_user_name($bb_post->poster_id) ?></small>

    seems like it should work. It doesn't error out, it's just blank after the " by "

    Is there a list of functions, similar to the WP codex, where I could learn about them?

    Thanks.

    Posted 1 year ago #
  4. bb_get_user($bb_post->poster_id) also did not work (does not error, just shows no output.)

    also
    $bb_post->poster_id does not return anything either.

    Posted 1 year ago #
  5. Try this

    echo bb_get_user($bb_post->poster_id)->user_login

    Or you can try to do it the way topics do it and just use this:

    post_author_link();

    That will also return the name as a link to their webpage.

    Worth a try I guess.

    Posted 1 year ago #
  6. If neither of those work, you need to echo $bb_post->poster_id and see if you're getting anything. If not, you gotta figure out wtf $bb_post contains.

    Posted 1 year ago #
  7. OK - will try. Thank you for your help.

    Posted 1 year ago #
  8. <?php _e(' by ')?><?php echo bb_get_user($bb_post->poster_id)->user_login ?>

    Returns the user's name. Perfect. Thanks.

    Posted 1 year ago #
  9. Update: the above was working, but on the command line, php -l complained:

    parse error, unexpected T_OBJECT_OPERATOR in ... that line

    I got this to work:

    <?php _e(' by ') ?><a href="<?php user_profile_link($bb_post->poster_id); ?>"><?php echo get_user_name($bb_post->poster_id); ?></a>

    That's what was suggested initially: I' m not sure what I did wrong the first time around, but this is what is working now, with no parse errors. Thanks.

    Posted 1 year ago #
  10. I wonder if the problem with this line:
    bb_get_user($bb_post->poster_id)->user_login

    is related to this style syntax and could be fixed in a similar manner (if necessary):
    http://bbpress.org/forums/topic/401?replies=42#post-2140

    Posted 1 year ago #

RSS feed for this topic

Reply

You must log in to post.

Code is Poetry.