WordPress.org

Ready to get started?Download WordPress

Forums

contributor list and conditional (4 posts)

  1. frescova
    Member
    Posted 5 years ago #

    I'm on 2.7

    I want to create a list on my home page side bar of only my blog's contributors, (not auhtor, editor, admin, etc.) ONLY users tagged as contributors.

    And, when a user is reading an article written by an author who IS a contributor I want to display a simple block of code.

    I looked through the template conditionals and tags but could not find specifics.

    Thans in advance

  2. mrlive158
    Member
    Posted 5 years ago #

    I think you should install some plugins can query the users' information then modify it with some if statements, and "role=contributor" :)

  3. frescova
    Member
    Posted 5 years ago #

    Do you know of any such plugin? I have been looking but can't find one...

  4. t31os
    Member
    Posted 5 years ago #

    If you can find the Userlevel for contributor you could just you use IF / ELSE....

    Something like this should work...

    <?php global $user_ID; if( $user_ID ) : ?>
    <?php if( current_user_can('level_10') ) : ?>
    
    Do what you want here...
    
    <?php else : ?>
    <?php endif; ?>
    <?php endif; ?>

    Level 10 is admin, so you'll just need to find out what a contributor is...

    Found that via google within a few moments, but should be able to adjust it to suit.... at least trim down on the PHP opening and closing...

    <?php
    global $user_ID; if( $user_ID ) :
    if( current_user_can('level_10') ) :
    ?>
    
    Your stuff here..
    
    <?php
    else :
    endif;
    endif;
    ?>

    Is how i'd personally do it, little easier for me to read...

    Looking at the roles and user-level codex page i'm not sure using user-level will work perfectly, you'll just have to try and see...

    http://codex.wordpress.org/Roles_and_Capabilities#Contributor

Topic Closed

This topic has been closed to new replies.

About this Topic