I'm new to drupal. I'm trying to do something very simple, but feel I'm going the wrong way about it.

I have html content that is in a block on my homepage. There is a button in this block that is a link to a content page.

I simply want to change this button to a different button, if the user is logged in.

I've read that using php filtering is the wrong way to go about this. What would be the best practice for doing this?

  • Would button have different actions for loggedin & non loggedin user?? If not @shabir ans is correct. If yes you can enable php filter and you will get php input format to apply conditions. Though php filter in non recommended for security measures. Dec 10, 2015 at 17:08
  • Yea, two different actions. @jphelan's solution seems like it will work best.
    – Ok'taz
    Dec 11, 2015 at 14:35

2 Answers 2


You can do this by simple css rule, no php, no logic

Inspect your element and check the body classes you will see class "logged-in" for logged in users and class "not-logged-in" for anonymous users. Just apply your changes like so:

.logged-in <block-class> <button> { // your style }

You can create two blocks and set the Roles Visibility settings to anonymous user or authenticated user depending on which one you want to display to that group. That way you don't have to enable php filter.

Your Answer

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

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