Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

a menu only for logged in users


natashome

Recommended Posts

Posted

hi

 

i am trying to display some links on the header only for logged in users. can someone help me out with the

<?php if (tep_session_is_registered('customer_id')) function?

so if the user is not registered other links should be displayed and once he logins others.

 

thank you

Posted

hi

 

i am trying to display some links on the header only for logged in users. can someone help me out with the

<?php if (tep_session_is_registered('customer_id')) function?

so if the user is not registered other links should be displayed and once he logins others.

 

thank you

 

<?php
 if( tep_session_is_registered( 'customer_id' ) &&  is_numeric( $_SESSION['customer_id'] ) ) {
   // Show only logged in menu
 } else {
   // Show menu for customers who are not logged in
 }
?>

Posted

<?php
 if( tep_session_is_registered( 'customer_id' ) &&  is_numeric( $_SESSION['customer_id'] ) ) {
   // Show only logged in menu
 } else {
   // Show menu for customers who are not logged in
 }
?>

 

hy

 

thank you for you reply...i am getting this error:

 

Parse error: syntax error, unexpected '<' in /home/content/includes/header.php on line 83

 

 

this is my menus and code in header.php:

 

<?php
 if( tep_session_is_registered( 'customer_id' ) &&  is_numeric( $_SESSION['customer_id'] ) ) {

<li class="submenu"><span class="submenu">My Account</span>
<ul class="level_2">
<li class="first"><a href="account_edit.php" title="Edit Account" class="first" onclick="this.blur();">Edit Account</a></li>
<li><a href="account_password.php" title="Change Password" onclick="this.blur();">Change Password</a></li>
<li><a href="account_history.php" title="Order History" onclick="this.blur();">Order History</a></li>
<li><a href="account_newsletters.php" title="Newsletter" onclick="this.blur();">Newsletter</a></li>
<li><a href="wishlist.php" title="Wishlist" onclick="this.blur();">My Wishlist</a></li>
<li class="last"><a href="logoff.php" title="logoff" class="last" onclick="this.blur();">LogOff</a></li>
</ul>
</li>

} else {

<li class="submenu"><span class="submenu">My Account</span>
<ul class="level_2">
<li class="first"><a href="login.php" title="login" class="first" onclick="this.blur();">Login</a></li>
<li class="last"><a href="create_account.php" title="create account" class="last" onclick="this.blur();">Create Account</a></li>
</ul>
</li>
 }
?>

 

line 83 is:

 

<li class="submenu"><span class="submenu">My Account</span>

Posted

<?php
 if( tep_session_is_registered( 'customer_id' ) &&  is_numeric( $_SESSION['customer_id'] ) ) {
?>
<li class="submenu"><span class="submenu">My Account</span>
<ul class="level_2">
<li class="first"><a href="account_edit.php" title="Edit Account" class="first" onclick="this.blur();">Edit Account</a></li>
<li><a href="account_password.php" title="Change Password" onclick="this.blur();">Change Password</a></li>
<li><a href="account_history.php" title="Order History" onclick="this.blur();">Order History</a></li>
<li><a href="account_newsletters.php" title="Newsletter" onclick="this.blur();">Newsletter</a></li>
<li><a href="wishlist.php" title="Wishlist" onclick="this.blur();">My Wishlist</a></li>
<li class="last"><a href="logoff.php" title="logoff" class="last" onclick="this.blur();">LogOff</a></li>
</ul>
</li>
<?php
} else {
?>
<li class="submenu"><span class="submenu">My Account</span>
<ul class="level_2">
<li class="first"><a href="login.php" title="login" class="first" onclick="this.blur();">Login</a></li>
<li class="last"><a href="create_account.php" title="create account" class="last" onclick="this.blur();">Create Account</a></li>
</ul>
</li>
<?php
 }
?>

You can't mix HTML and PHP code like you were trying to do.

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Posted

Edit .. I was looking at Germs code ;)

 

The code Germ posted is perfect.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...