Support » Plugins » Hacks » display links to specific user roles

  • Resolved cinemaduro


    I have created two new roles with basically the same access as subscribers except they can both read private pages. I want to display a list of links in a php widget that is different depending on what role the logged in user is.

    I’m not real hot with PHP code, but could I do something like:

    get role_name
    if role_name is AAAA then (display code)
    if role_name is BBBB then (display code)
    (display default code)

    I have some code that almost does what I want, but it is based on what privledges a role has instead of what the actual role is. Since both new roles have the same privledges, I can’t differentiate. Here’s that particular code:

    if ( current_user_can( ‘read_private_pages’ ) ) { ?>
    Page for Role AAAA

    <?php } else { ?>
    Page for Role BBBB
    <?php } ?>

    <?php } ?>

    Any thoughts? Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • I just found out that apparently you can say use roles with current_user_can and not just privileges. Haven’t tested it yet, but going to close the thread for now.


    if ( current_user_can( 'Editor' ) ) { ?>
    display this code
    <?php } else { ?>
    display that code
    <?php } ?>
    <?php } ?>

    hey i have like 5 user roles how do i show a link if user A from user role A is logged on ?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘display links to specific user roles’ is closed to new replies.