Hi

I am trying to restrict access to nodes so that only the author can view them.

I can hide the content easily,m but I can't figure out how to change the node title to, "Access Denied"

My node-contenttype.tpl.php is:

<?php
global $user;
if ($node->uid == $user->uid) { ?>

<div id="<?php print $node_id; ?>" class="<?php print $classes; ?>">
  <div class="node-inner">

    <?php if (!$page): ?>
      <h2 class="node-title">
        <a href="<?php print $node_url; ?>" rel="bookmark"><?php print $title; ?></a>
        <?php print $unpublished; ?>
      </h2>
    <?php endif; ?>

    <?php if ($submitted): ?>
      <div class="node-submitted"><?php print $submitted; ?></div>
    <?php endif; ?>

    <?php print $picture; ?>

    <div class="node-content"><?php print $content; ?></div>

    <?php if ($terms): ?>
      <div class="node-terms"><?php print $terms; ?></div>
    <?php endif; ?>

    <?php if ($links): ?>
      <div class="node-links"><?php print $links; ?></div>
    <?php endif; ?>

  </div>
</div> <!-- /node -->
<?php
}
else { 
  $node->title = 'Access Denied';
  $content = 'Sorry, you don\'t have permission to view this person\'s registration details.';
  ?>
  
<div id="<?php print $node_id; ?>" class="<?php print $classes; ?>">
  <div class="node-inner">

    <div class="node-content"><?php print $content; ?></div>

  </div>
</div> <!-- /node -->
<?php } ?>

The $node->title value isn't working, the original title of the node is still displaying.

How do I change this?

Thanks

Glenn

Comments

glennnz’s picture

SOLVED

drupal_set_title('Access denied');