WordPress.org

Ready to get started?Download WordPress

Forums

Page of Authors Problem (12 posts)

  1. hoss9009
    Member
    Posted 2 years ago #

    I'm desperately trying to figure out why the User Photo plugin isn't working.

    I'm creating a page of profiles (similar to a page of posts). I'm using the User Photo plugin to call my user profile pictures. Here's my code, thus far:

    <?php get_header(); ?>
    <div id="inside-content"><?php if(have_posts()) : while(have_posts()) : the_post(); ?>
    <h2 id="inside-h2" class="chunk orange"><?php the_title(); ?></h2>
    <?php the_content(); ?>
    <?php endwhile; endif; ?>
    
    <div id="ap-content">
    <?php
    // Get the authors from the database ordered by user nicename
    global $wpdb;
    $query = "SELECT ID, user_nicename from $wpdb->users ORDER BY user_nicename";
    $author_ids = $wpdb->get_results($query);
    // Loop through each author
    foreach($author_ids as $author) :
    // Get user data
    $curauth = get_userdata($author->ID);
    // If user level is above 0 or login name is "admin", display profile
    if($curauth->user_level > 0 || $curauth->user_login == 'admin') :
    // Get link to author page
    $user_link = get_author_posts_url($curauth->ID);
    // Set default avatar (values = default, wavatar, identicon, monsterid)
    $avatar = 'wavatar';
    ?>
        <div class="project">
            <h3 class="project-title chunk"><a href="<?php echo $user_link; ?>" title="<?php echo $curauth->display_name; ?>"><?php echo $curauth->display_name; ?></a></h3>
            <h4 class="orange chunk"><?php echo $curauth->subtitle; ?></h4>
            <a href="<?php echo $user_link; ?>" title="<?php echo $curauth->display_name; ?>" target="_self"><?php userphoto_the_author_photo(); ?></a>
        </div>
    
    <?php endif; ?>
    <?php endforeach; ?>
    <div class="clear"></div></div><!-- end #ap-content -->
    
    <div class="clear"></div></div><!--- INSIDE-PAGE -->
    <div class="clear"></div></div><!-- CONTENT -->
    <div class="clear"></div></div><!-- MAIN -->
    <?php get_footer(); ?>

    I can't get the User Photo plugin to call multiple, different users' photos. Currently it's just calling in the user's photo who created the page (me).

    Thoughts? Help? (Preemptive) thanks!

    PS. I don't know if this is appropriate, but I'm willing to pay for the help (paypal).

  2. hoss9009
    Member
    Posted 2 years ago #

    Sorry... also, am I calling in the authors correctly?

  3. hoss9009
    Member
    Posted 2 years ago #

    Sorry... one more thing... I would like pagination on this... am I anywhere close to getting that too?

  4. hoss9009
    Member
    Posted 2 years ago #

    $ for anyone who can fix this... (via paypal)

  5. petervanderdoes
    Member
    Posted 2 years ago #

    Try changing :
    $author_ids = $wpdb->get_results($query);

    to

    $author_ids = $wpdb->get_results($query, ARRAY_A);

    $wpdb->get_results returns an object by default.

  6. hoss9009
    Member
    Posted 2 years ago #

    Hmmm... The users (all together) went away.
    Here's my page.
    Other ideas?
    I just can't figure out how to get the plugin to pull each individual user's profile pic.

  7. petervanderdoes
    Member
    Posted 2 years ago #

    Forget the Array_A thing, my mistake. I shouldn't work on 3 things at the same time lol.

    How many users do you have? I see two pictures on the page.

  8. rfair404
    Member
    Posted 2 years ago #

    Try passing the author id into the userphoto_the_author_photo() function like this:

    userphoto_the_author_photo(authorId);

  9. hoss9009
    Member
    Posted 2 years ago #

    Sorry @rfair, when I use your code, it throws a link above the pictures saying "authorId" w/ a link to the author.php of that user.
    @petervanderdoes 2 users... the pic you see is the admin pic (user on the left).

  10. petervanderdoes
    Member
    Posted 2 years ago #

    Add after this line:

    if($curauth->user_level > 0 || $curauth->user_login == 'admin') :
    global $authordata;
    $authordata=$curauth;

    or a bit nicer solution as I personally loath globals :)
    change

    <a href="<?php echo $user_link; ?>" title="<?php echo $curauth->display_name; ?>" target="_self"><?php userphoto_the_author_photo(); ?></a>

    to

    <a href="<?php echo $user_link; ?>" title="<?php echo $curauth->display_name; ?>" target="_self"><?php echo  userphoto__get_userphoto($curauth->ID, 1, '', '', '', ''); ?></a>
  11. hoss9009
    Member
    Posted 2 years ago #

    Any idea how to limit the number of users on the page to 5 and then paginate it?

  12. hoss9009
    Member
    Posted 2 years ago #

    @petervanderdoes I'll give it a whirl

Topic Closed

This topic has been closed to new replies.

About this Topic