• Resolved steveone86

    (@steveone86)


    Hello, thanks for this great plugin. I am tying to ge the following statement to work and I do not know how to pass the user id. Can you help me with this?

    <?php
    if ( has_wp_user_avatar($user_id) ) {
    echo get_wp_user_avatar($user_id, 96);
    } else {
    echo ‘<img src=”my-alternate-image.jpg” />’;
    }
    ?>

    I would like to output a different size image for authors and contributors. How can i do this?

    Thanks for your help

    http://wordpress.org/plugins/wp-user-avatar/

Viewing 1 replies (of 1 total)
  • Hi, that code is one way of checking if a user has an avatar and showing something else if he doesn’t. That’s not exactly what you’re asking for, it seems.

    I would use something like this, but I’d need more info from you about what kind of page you’re using this code on, because you may need to change the $user_id variable:

    <?php
    $user_id = get_the_author_meta('ID');
    // Check for a capability that authors have and contributors don't
    if(user_can($user_id, 'publish_posts')) {
      echo get_wp_user_avatar($user_id, 96);
    } else {
      echo get_wp_user_avatar($user_id, 32);
    }
    ?>

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

Viewing 1 replies (of 1 total)
  • The topic ‘How do i pass user id for this statement?’ is closed to new replies.