WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] help with php code inserted in header.php file (2 posts)

  1. tkm
    Member
    Posted 5 years ago #

    Hi,

    I've inserted the below php if statement code into the header.php file. The code checks to see if a user is logged in or not and then shows some text accordingly. For some reason the if part is not being recognised and else text is always being shown. I have this same php code in the index.php template file and it works fine. So, it seems to be just an issue with the header.php file. Any help would be much appreciated!

    if(isset($HTTP_SESSION_VARS['user_ids']) && $HTTP_SESSION_VARS['user_ids'] != "")
    {
      $user_ids = $HTTP_SESSION_VARS['user_ids'];
      $Query_user_log = mysql_query("select * from  wp_users where ID = '$user_ids'");
      $num_log = mysql_num_rows($Query_user_log);
      if($num_log > 0)
      {
      $result_log= mysql_fetch_array($Query_user_log);
      $user_name = $result_log['user_nicename'];
      }
      echo "<<em>output this text</em>> ";
      }
      else
      {
      echo "<<em>output this text instead</em>>";
      }
  2. tkm
    Member
    Posted 5 years ago #

    Hi guys,

    I ended up findng a resolution after much searching online. Here is the resolution:

    http://blog.ginchen.de/en/2008/08/15/session-variablen-in-wordpress/

Topic Closed

This topic has been closed to new replies.

About this Topic