以编程方式显示drupal中的隐藏按钮[关闭]

I've got a sign up page with an anchor button for signing up, but when a user is logged in the form is hidden but the content should still be visable just hiding the join now button, im trying to display the button based on the vistor id, so basically i only want to show it to anonymous users not authenticated

 <?php
global $user;
  if ($user->uid)

return;

else
{
print '<div id="landing-left-button">
    <a class="button" href="#join-anchor">Click Here To Join</a></div>';
}
?>

A better way would be to do it like this:

if (! user_is_logged_in()) {
  print <<<EOT
    <div id="landing-left-button">
      <a class="button" href="#join-anchor">Click Here To Join</a>
    </div>
EOT;
}

I'm not quite sure what is your use-case... But in this case, you will have to use globals. That's how we usually check/get user's data.

<?php
 if (user_is_logged_in()){
  // do something for logged in users.
 }
 else{
  //do something for anoynmous users. 
 }
?>

user_is_logged_in() function returns TRUE if the user is logged in (duh!).