A little PHP coding help please

By kkegans - February 22, 2013

I am using the Membership plugin foir the first time and I am not fluent in PHP. I am attempting to display a different set of navigation links to logged in users an non-logged in users. This is the code I have on the site now:

<div id="header">
  <?php include 'include/header_inc.php' ?>
  <?php if ($CURRENT_USER): ?>
   <?php include 'include/member_navigation_inc.php' ?>
   <?php else: ?>
     <?php include 'include/navigation_inc.php' ?>
  <?php endif ?>

The problem is, if the usere is logged on, both navigation includes are being displayed in the same space. I am sure it is a problem with this code, and could sure use some input to assist me here.

Thanks!

Kurt

CMSB Rocks!



Thanks,



Kurt

By Dave - February 22, 2013

Hi Kurt, 

Your code looks good.  What is displayed when you "View Source" in the browser?

Sometimes when I'm working on something I start simple (even now) to make sure things are working, like this:

<?php if ($CURRENT_USER): ?>
  Current User is logged in.
<?php else: ?>
  No one is logged in.
<?php endif ?>

Let me know if that works and what "view-source" shows (does it show the includes you expected, PHP code, errors, or something else? 

Hope that helps!

Dave Edis - Senior Developer
interactivetools.com

By kkegans - February 22, 2013

Dave,

Thanks for the tip...it makes a lot of sense.

I don't know what was going on but I tried your example and everything worked as expected, then reloaded my original code and it worked as expected.

Thanks again,

Kurt

CMSB Rocks!



Thanks,



Kurt