I've been searching around the forums, but not finding anything which covers what I'd like to do.

Which is:

I'm setting up a site which will consist of registered users and subscribed (paying) members. I'd like everyone except subscribed members to only see the teaser of a set of nodes, but sub members can see the whole node.

Anyone know of a module, or even PHP snippet I can put into node.tpl.

Thanks!

Steel Rat

Comments

davemybes’s picture

Add the following code somewhere in node.tpl.php:

global $user;
$approved_roles = array('board', 'sales', 'engineer'); // change the roles here to what you want

if (is_array($user->roles)) {
  if (count(array_intersect($user->roles, $approved_roles)) > 0) {
    $allowed = "yes";
  } else {
    $allowed = "no";
}}

Then add a check for $allowed to the $teaser check like this:

  if($node->teaser && $allowed == "no") {
    print $node->teaser;
  }
  if ($allowed == "yes") {
    print $content;
  }

Haven't tried this out, but it seems to me that it should work. You will need to ensure that your node has a teaser, or nothing will print out for the non paying users.

______________________________________________________________________________________________________
Need help? Check the FAQ and the Handbooks first.

______________________________________________________________________________________________________

Steel Rat’s picture

Thanks,

That looks like it might work.

I'm wondering if this will also work with Book nodes. Meaning non-sucscribers won't be able to see subsequent book pages.

Steel Rat
Drupal Site: RPGMapShare.com

davemybes’s picture

I think that it should as node.tpl.php governs all nodes, independent of type - unless you specifically add code into it, or use node-specific tpl.php files.

______________________________________________________________________________________________________
Need help? Check the FAQ and the Handbooks first.

______________________________________________________________________________________________________

artatac’s picture

have tried this - adding both snippetts to node.tpl.php - doesnt seem to work. Am I missing something?