WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] help with php code inserted in header.php file

[Resolved] help with php code inserted in header.php file

  • 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>>";
      }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] help with php code inserted in header.php file’ is closed to new replies.