php - set display by role programmatically in Drupal 7 -
i want display text link, <p><a href ="register">click here register.</a></p>
in body of larger block of text on page , want link show when logged in. want use php conditional show other link when instead anonymous on site,
<p>you need login before can register. please <a href="login">click here login.</a>
i want code like:
<?php if user=="logged-in"; echo "<a href ='register'>click here register.</a>"; else echo "<a href ='login'>click here login.</a>" ?>
i know must not have written perfect php not have problems php, need drupal syntax if user == "logged-in"
, if user == "not-logged-in"
.
i not want use block , start setting visibility role. want use code described.
thanks.
see docs
you want this. both of link descriptions need work though. you'd want display both register , login link anonymous users.
<?php if (user_is_logged_in()){ //user logged in } else{ //user not logged in } ?>
Comments
Post a Comment