1

I use Drupal-7.14 and the default theme,Bartik 7.14. I added "my content type" as a new content type. Then I could see a new content foo by the url hostname/content/foo.

The content foo shows the author and the date because I checked

Structure > Content Types > my content type > edit > Display Settings > Display author and date information.

Only the date should be shown from logouted users. The author should NOT be shown for logouted users.

How can I hide the author information from the non-member.

3

If you copy the node.tpl.php file from the templates directory and create a node--mycontenttype.tpl.php file you should see the following around line 91:

<?php if ($display_submitted): ?>
  <div class="meta submitted">
    <?php print $user_picture; ?>
    <?php print $submitted; ?>
  </div>
<?php endif; ?>

Simply change it to this:

<?php if ($display_submitted): ?>
  <div class="meta submitted">
    <?php print $user_picture; ?>
    <?php if ($logged_in == TRUE): ?>
      <?php print $submitted; ?>
    <?php endif; ?>
  </div>
<?php endif; ?>

The $logged_in variable is a node template variable that has the value of TRUE if a user is logged in.

In this snippet you're just saying if the user is logged in, then display the submitted information.

Don't forget to clear your caches!

EDIT

Apologies, I've read the question properly now. The following should do what you want.

<?php if ($display_submitted): ?>
  <div class="meta submitted">
    <?php print $user_picture; ?>
    <?php if ($logged_in == TRUE): ?>
      <?php print $submitted; ?>
    <?php else: ?>
      <?php print $date; ?>
    <?php endif; ?>
  </div>
<?php endif; ?>

This will display the entire submitted by text for authenticated users, and just the date for anonymous users.

3
  • Thanks a lots for your kind answer. "print $submitted" may include the posted date. I hate only username. Please show me how to hide username without erasing the date. May 28 '12 at 9:13
  • I've noticed that your answer has almost met my question. I could use $name and $date instead of $submitted in node--mycontenttype.tpl.php file. Thank you very much again. May 28 '12 at 10:31
  • Awesome, I've edited the answer to reflect this so it's easier for other people in the future. Don't forget to mark the answer as accepted if it worked for you :-)
    – Chapabu
    May 28 '12 at 11:00
-1

In D7 navigate to admin/people/permissions

Find View user profiles permissions and grand it as you wish to be.

3
  • 1
    admin/people/permissions > User > View user profiles,I tried it,the first check off,the second and the third checks on, but an author name was not hidden.I will continue waiting for other solutions. May 28 '12 at 6:52
  • Which theme you're using?
    – niksmac
    May 28 '12 at 7:04
  • I use Drupal-7.14 and the default theme,Bartik 7.14. May 28 '12 at 7:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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