• Resolved Nahum

    (@nahummadrid)


    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?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Same way you’d do it on a single site. If you just want to show the avatar… just get_avatar.

    Thread Starter Nahum

    (@nahummadrid)

    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.

    Thread Starter Nahum

    (@nahummadrid)

    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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Check if user exist as Author on Site?’ is closed to new replies.