1

I have a drupal 7 local website and I have a popup when you enter the website. In this popup, I want to show a button leading to an article, if the user is logged in, or else two buttons leading to the login page and the register page. The popup is an html file. I tried with javascript(hiding the buttons and make them visible when the html file loads) but I can't find how to check if the user is logged in. Is there a way to achieve that using only php, and how can I do that?I am a new developer and I don't know php well.

1 Answer 1

1
<?php

if(user_is_logged_in()) {
  echo '<a href="some link">Private</a>';
} else {
  // show two buttons
}

?>

Have a look at the api here

Sign up to request clarification or add additional context in comments.

1 Comment

and how can I put it into the html file?also, is there a way to make the buttons(a hrefs) visible?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.