Hi everyone and Good day!Am new to php and I have a problem with the code below.

<?php if (is_user_logged_in() ) //only logged in user can see this 'echo'<href="http://localhost/itsz.com/profile">Profile</a>';

What i want it to do is to only show the link "profile" 'only' to logged in users but it doesen't. Instead, profile link is shown to both loggedin and non logged in users. i know i have made an error in the code syntax but i have no idea where. It was just a copy and paste game and edit a little.Php coders help me. Thank you.

Member Avatar

Get rid of the single quotes around echo:

<?php if (is_user_logged_in() )
    echo '<href="http://localhost/itsz.com/profile">Profile</a>';

However if it's showing in all cases, it means that is_user_logged_in() isn't working properly. For that we'd need to see the underlying code as we don't have crystal balls.

Wow! its now working like magic! Cant believe those damp '' troubled me for weeks. I need some basic php tutorials.Thanks and May God Bless youuu...