WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Check if user exist as Author on Site? (4 posts)

  1. nm
    Member
    Posted 3 years ago #

    How can run a check to see if a user exists on a specific site?

    I had thought about trying to see if the user had any posts on the site but it doesn't quite work.

    <?php if count_user_posts( $post->post_author ) > 0 )  : ?>
    show this member avatar (using buddypress)

    I'm thinking it would probably be better to just see if the user exists at all on the specific site. Is there something to do with the user roles that I can do?

  2. Same way you'd do it on a single site. If you just want to show the avatar... just get_avatar.

  3. nm
    Member
    Posted 3 years ago #

    I'm sorry I should've explained further what I'm trying to do.

    <?php
    global $bp;
    $username = bp_get_member_name();
          ?>
    
    <?php if ( bp_has_members('include='.$post->post_author) && username_exists( $username ) )  : ?>
    <?php bp_member_avatar('type=full');?>
    <?php else:?>
    mystery_man will show
    This user has no posts
    <?php endif;?>

    I was trying to show a users bp avatar on different subdomains' author.php template. In sense force /author/bpusername even if the member didn't have any posts on the site.

    The hurdle for me was that when a bp member didn't exist on the site, something funky would happen in the place of the avatar, it would show a bunch of members avatars. Everything works fine for users that do have posts and exist on the site so the author.php looks like the site's author but i can also show BP info and links.

  4. nm
    Member
    Posted 3 years ago #

    Ok the solution was so simple. I'm embarrassed.

    I realized that I had the bp stuff in the wrong place
    I just moved if have posts above all the BP stuff.

    <?php if (have_posts()) ?>
    <?php if ( bp_has_members('include='.$post->post_author) )?>

    Thanks andrea for your replying. I shoud've known it would be so easy it was hard.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.