The post will show you how in Drupal 6 to display a block for the administrator showing how many comments by anonymous users are waiting approval and also provide a link to the approval list.

Pre-setup

This post assumes you have your permissions set so anonymous users can post comments (with approval), and you also have the core module PHP filter installed.

Please comment if you need any help with the Pre-setup

Creating the Block

Go into Admin => Blocks => Add block

Enter a description such as Comments Waiting

Enter the following code into the Block body

<?php
  global $user;
 
  if ($user->uid == 1) {
 
  $sql = 'SELECT COUNT(c.cid) FROM {comments} c WHERE c.status = 1';
 
  $num_comments = db_result(db_query($sql));
 
  return "<div align='center'>
          <p>There are <strong>$num_comments</strong> comment(s) waiting to be 
          <a href='?q=admin/content/comment/approval'>approved</a></p></div>";
  }
?>

Change the Input format to PHP

Under specific visibility settings select “Select the option Show if the following PHP code returns TRUE (PHP-mode, experts only). “ and enter the following code.

<?php
  global $user;
 
  if ($user->uid == 1) { 
 	return true;
  }
?>

 

 

Save the block

Remember to assign your new block to a region