2

I've got custom content-type. On the main page I set teaser display of contents and I decided to show off only several fields there. Next to each content I can notice text "Read more". After entering it, I am redirected to full display of contents (There are show off all fields).

Action, described above can be done by everyone. But, I'd like to allow it only logged in users. How can I disabled it for users who aren't logged in.

2

Use the premium content module

Restricts access to premium content by role and provides a general API for other modules to help decide if a user has access to premium content.

This is useful on a news or membership site where teasers are available to the general public but the full body is only available to privileged users. Premium nodes appear in listings with full title and teaser available to anyone. If a user does not have adequate privileges, the default behavior is to show a simple message, but you can use Panels or theme overrides to do more custom things.

All you need to do is enable the module, go to the edit page(admin/structure/types/manage/yourcontenttype) of the content type you want to make premium, and on the publishing options tab, select premium content

  • Thanks for your answer. Is the necessity to create new content-type? – user19455 Aug 13 '13 at 11:57
  • When user isn't logged in teaser is shown off and entering doesn't matter - it's no result. How can I add text "You have to be logged in"? – user19455 Aug 13 '13 at 12:25
  • for your content type, create a node-yourtype.tpl.php file and copy the content of the node.tpl.php file into it and do a if($teaser){//check if logged in if not, print a link, which links to the login page} – 4life Aug 13 '13 at 12:34
  • Unfortunately, there are errors. When I go to add content, I see Notice: Undefined property: stdClass::$nid in premium_node_level_data() (line 319 from .../sites/all/modules/premium_content/premium.module). Notice: Undefined index: machine_name in premium_form_alter() (line 160 from .../sites/all/modules/premium_content/premium.module). – user19455 Aug 13 '13 at 12:53
  • drupal.org/node/1482896#comment-6250542 should fix the problem – 4life Aug 13 '13 at 13:03

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.