Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Populating BP Profile Loop for author of a WP Post

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

  • atburi
    Participant

    @aburi

    This worked 🙂

    <?php if ( bp_has_profile( array( 'user_id' => $user_id ) ) ) : ?>

    Is this the best solution?

    This would work (& does work):
    bp_has_profile(‘user_id=’ . get_the_author_meta( ‘ID’ ) )

    or you could grab the user id from $post->post_author

    I’m assuming you’re running this in a single post loop.


    atburi
    Participant

    @aburi

    Thanks for the response, @hnla

    Indeed, that works; just wasn’t sure how to properly code inside a php bracket like that.

    I’m running the member’s profile loop in the sidebar of the single post page, so this would be outside the single post content loop. However, also in the side bar I use the function:

    bp_core_get_userlink( $post->post_author ) )

    and that does work, so somehow it’s getting the correct member ID outside the loop?

    If I wanted to use $post->post_author to get the ID, would it look like:

    if ( bp_has_profile( $post->post_author ) ) : ?

    $post is available as soon as you hit a post/page so doesn’t have to be in the loop

    Think my earlier example holds good for passing the id to bp_has_profile but I’d probably do $user_id = $post->post_author;


    atburi
    Participant

    @aburi

    Thanks Hugo, all makes sense….

    I’ll leave it that and mark as resolved!

    Marking as ‘resolved’ then, re-post if further issues arise.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Resolved] Populating BP Profile Loop for author of a WP Post’ is closed to new replies.
Skip to toolbar