Forums

[resolved] php if help (2 posts)

  1. envyzage
    Member
    Posted 1 year ago #

    Ok, let me start off by saying that I am new to all of this and I appreciate your patience. I am trying to add a menu to my website that is only visible to a specific role. I found this wpmu.org and it provided the base code but i cannot get it to work.

    <?php if ( current_user_can( 'delete_others_posts' ) ) { //only admins and editors can see this ?>

    • Secret Menu Item
    • Other Restricted Link

    <?php } else { ?>

    • General Menu
    • Anyone Can See This

    <?php } ?>

    To be honest I'm not entirely sure where i should be putting it but I'm assuming it should go where i would like the menu. I was also curious if i needed to add something to the functions.php for the if function but i assumed it would already be there. When I use the code it displays all of the listed items. Again I appreciate all of your help in advance.

    **UPDATE**
    You were correct. Thank you very much.

  2. coopersita
    Member
    Posted 1 year ago #

    I would think it would go in the header.php file. Just put it where you want your menu to be.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags