PHP Brain Fart Smelling Up the Code

LPH

Well-known member
OK. Now that I have your attention :)

The idea is to add a link to /wp-admin if the user_id equals a particular number.

This is the original code in my header.php file.

Code:
                <?php
                if ( is_user_logged_in() ) {
 
                    global $current_user, $XF;
                    get_currentuserinfo();
 
                    echo '<ul id="member" class="loggedin_menu_class">
                    <li><a href="/community/members/'. strtolower($XF->visitor->get('username')) . '.' . $XF->visitor->get('user_id') .'">'.$current_user->display_name.'</a></li>
 
                    <li><a href="/community/conversations/">Inbox</a></li>
                    <li><a href="/community/logout">Log Out</a></li>
                    </ul>';
 
                } else {
                    /* wp_nav_menu( array( 'theme_location' => 'primary' ) ); */
 
 
                    echo '<ul id="member" class="loggedin_menu_class">
                    <li><a href="/community/login">Log In or Sign Up</a></li>
                    </ul>';
                }
                ?>


And here is the idea .. .but something is terribly wrong !

Code:
                <?php
                if ( is_user_logged_in() ) {
 
                    global $current_user, $XF;
                    get_currentuserinfo();
 
                    echo '<ul id="member" class="loggedin_menu_class">
                    <li><a href="/community/members/'. strtolower($XF->visitor->get('username')) . '.' . $XF->visitor->get('user_id') .'">'.$current_user->display_name.'</a>';
 
if (user_id==6) {
echo '<ul class="sub-menu">
<li><a href="/wp-admin">Admin Panel</a>
</li>
</ul>';
}
 
echo '</li>
 
                    <li><a href="/community/conversations/">Inbox</a></li>
                    <li><a href="/community/logout">Log Out</a></li>
                    </ul>';
 
                } else {
                    /* wp_nav_menu( array( 'theme_location' => 'primary' ) ); */
 
 
                    echo '<ul id="member" class="loggedin_menu_class">
                    <li><a href="/community/login">Log In or Sign Up</a></li>
                    </ul>';
                }
                ?>

Any thoughts on what the heck I'm doing wrong ? it's probably so obvious :)
 
OK. I decided to use $site_admins instead and it appears to now work.

Code:
              <?php
                if ( is_user_logged_in() ) {
 
                    global $current_user, $XF;
                    get_currentuserinfo();
 
                    echo '<ul id="member" class="loggedin_menu_class">
                    <li><a href="/community/members/'. strtolower($XF->visitor->get('username')) . '.' . $XF->visitor->get('user_id') .'">'.$current_user->display_name.'</a>';
                   
                   
                    if ( $site_admins = array ( 'insert admins' ) ){
                        echo '<ul class="sub-menu">
                        <li><a href="/wp-admin">Admin Panel</a></li>
                        </ul>';
                    }
                 
                   
                    echo '</li>
 
                    <li><a href="/community/conversations/">Inbox</a></li>
                    <li><a href="/community/logout">Log Out</a></li>
                    </ul>';
 
                } else {
 
                    echo '<ul id="member" class="loggedin_menu_class">
                    <li><a href="/community/login">Log In or Sign Up</a></li>
                    </ul>';
                }
                ?>
 

Similar threads

Back
Top Bottom