I like to have the same result in a template if the user is logged-in or is on the front page.

So if the user is not logged-in nor on the front page, it should be the same result as if the user is logged in and not on the front page.

I got

<?php if ($logged_in): ?>

Do something

  <?php else: ?>

Do Something Other

<?php endif; ?>

How to extend this to force drupal to do the same on front as for the logged in user if the user is not logged in but viewing the front page

In other words how to get if drupal_is_ _on_front OR $logged_in


I am a php newbee

thank you for an explanation

  • This is a plain PHP question: You are asking how to use an if() to check the values returned from two different functions. Drupal doesn't change the PHP syntax, and our task is not teaching PHP.
    – apaderno
    Aug 5, 2016 at 4:46

2 Answers 2


You would do something like

<?php if (user_is_logged_in() || drupal_is_front_page()): ?>
  Do something
<?php endif;?>



I think you will want the following:

<?php if ($logged_in || $is_front_page): ?>
    Do something
<?php endif;?>
  • it seems I do not understnad the syntax correctly. So if there are two functions like (user_is_logged_in and drupal_is_front_page How does the line look? Like this? <?php if (user_is_logged_in(): || drupal_is_front_page():) ?>
    – Josh
    Aug 4, 2016 at 18:39
  • Have a look at PHP's manual about Alternative syntax for control structures
    – mchar
    Aug 4, 2016 at 19:36

Not the answer you're looking for? Browse other questions tagged or ask your own question.