Support » Fixing WordPress » Display a custom image only if user role is contributor

  • Hi,
    I want to display an image next to a certain users in comments. In this particular case like a “Trusted User Badge”. So every time our selected users post a comment the badge a piers next to them.

    I got the image ready and set up but it shows for all users that comment.

    1 What code would you use to display an image only for users with role contributor and hide it if role = subscriber?

    2. Is there a better way of doing this?

    Thanks for your help.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter Eddie

    (@momentumsm)

    Thanks for your reply,

    But I already lokad at that particular plugin. The image I’m trying to add has to be separate from users avatar.

    I guess what I’m after is a bit of code that will allow me to hide the img if user is a subscriber or any other and display the img if the role = contributor.

    btw: the comments on site are allowed only for registered users.

    Thread Starter Eddie

    (@momentumsm)

    Is it possible to do this using CSS?

    Seems like you could use user-edit.php but I know nothing about php and very little about css.

    Thread Starter Eddie

    (@momentumsm)

    Thanks for the try… 🙂

    You can add

    <?php if ( current_user_can('contributor') ) : ?>
     Your Image here
    <?php endif; ?>

    This should show the code only to the contributor.

    I’m looking for something similar but not for an image display, yet for a Menu display (text format). I have Contributors and “Basic” role users (Custom role deployed by the Members plugin).

    In the navigation menu, when the user logs in, there’s a link to take them to their profile, I have duplicated the functionality of the profile of a Contributor template and stripped down some options to reflect on a Basic profile template, the problem is, I cant figure out how to distinguish the user role when logged in and switch Menu links pending on their user role to redirect each one separately pending on the identified role they have been assigned.

    Anyone out there know of a plugin or code that would allow me to complete such task?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Display a custom image only if user role is contributor’ is closed to new replies.