• Resolved Andune

    (@andune)


    Im using a custom menu on my site that isn’t originally part of the theme.
    Part of the menu is supposed to show “Logged in as: *Username*” using the code “Logged in as: <?php echo $user_identity; ?>”. That code (and everything else required for the menu) is in its own php file with the name “menu.php”.

    At first i put “<?php include (TEMPLATEPATH . ‘/menu.php’); ?>” before the header in the code to every page i wanted the menu on. Sure, it worked brilliantly but soon i realised that this was a stupid idea because;
    1. Putting it before the DOCTYPE and everything else that’s in the header.php created loads of validation errors.
    2. It was annoying to put it into the code on every page i wanted it on.
    So i moved “<?php include (TEMPLATEPATH . ‘/menu.php’); ?>” into the header.php file right after the <body> tag and all the validation errors disappeared.

    The only problem now was while everything else in the menu worked, the part showing your username didn’t, instead of showing “Logged in as: *Username*” it just showed “Logged in as:”. It seems as as soon i move it into the header “<?php echo $user_identity; ?>” displays nothing. The php code works, i know because if i change $user_identity to lets say $user_ID i get “Logged in as: *User ID*”.

    What is it that makes $user_identity stop working? Is there any other code to use instead?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Problem with $user_identity in header’ is closed to new replies.