Site icon Catch Themes

Inserting PHP code above the header

Hello! I have this piece of PHP code which I am trying to insert just above the header:
<?php
  if (is_user_logged_in()) {
    global $current_user;
    get_currentuserinfo();
    echo ‘Welcome ‘ . $current_user->display_name;
  } else {
	echo ‘Welcome Guest!‘ "<a href='page_id=43'>Login or register to buy credits.</a>";
}	  
?>
I have tried inserting it into various places in the header.php file and every time it gives me a HTTP500 error. I'm not exactly sure why, so I was looking for advice on where I should put it so that it either appears just above the entire header (to the right, which I can do with CSS) or just below the social media buttons. Thanks!
Exit mobile version