Which hooks should I implement in Drupal 7 that are the equivalent of hook_comment() and hook_nodeapi()? This is the code I am using for Drupal 6:

/**
 * @Implement of hook_nodeapi()
 */
function mycaptcha_nodeapi(&amp;$node, $op, $teaser, $page) {
  global $user;
  switch ($op) {
    case 'insert':
      if (isset($_SESSION['mycaptcha_ask_key'])) {
        unset($_SESSION['mycaptcha_ask_key']);
      }
    break;
    case 'validate':
      if ($node-&gt;mycaptcha_ask) {

        mycaptcha_ask_form_validate($node-&gt;mycaptcha_ask);
      }
    break;
  }
}

/**
 * @Implement of hook_comment()
 */
function mycaptcha_comment(&amp;$comment, $op) {
  global $user;
  switch ($op) {
    case 'insert':
      if (isset($_SESSION['mycaptcha_ask_key'])) {
        unset($_SESSION['mycaptcha_ask_key']);
      }
    break;
    case 'validate':
      if ($comment['mycaptcha_ask']) {
        mycaptcha_ask_form_validate($comment['mycaptcha_ask']);
      }
    break;
  }
}


What are the equivalent hooks that I should implement for Drupal 7, to obtain code equivalent to the one I am actually using for Drupal 6?

from kiamlaluno's help. i changed the code to the following. but the validation still doesn't work. but the above code(hook_comment) works ok under drupal 6.

what's wrong with my code in drupal 7.

function mycaptcha_comment_insert($comment) {  
  global $user;
      if (isset($_SESSION['mycaptcha_ask_key'])) {
        unset($_SESSION['mycaptcha_ask_key']);
      }
   }

function mycaptcha_form_comment_form_alter(&amp;$form, &amp;$form_state, $form_id) {
    global $user;
  $form['#validate'][] = 'mycaptcha_comment_validate';
}

function mycaptcha_comment_validate($form, &amp;$form_state) {
    global $user;
      if ($comment['mycaptcha_ask']) {
        mycaptcha_ask_form_validate($comment['mycaptcha_ask']);
      }

  }
I will reply to your question basing on the value for $op shown in your code snippet.
hook_nodeapi(), &quot;insert&quot;
The equivalent for Drupal 7 is hook_node_insert(), which receives just one parameter: $node.
hook_nodeapi(), &quot;validate&quot;
The equivalent for Drupal 7 is hook_node_validate(), which receives three parameters: $node, $form, &amp;$form_state.
The implementations of hook_node_validate() don't usually use the last parameter, but they check the values of the properties for the $node object.
hook_comment(), &quot;insert&quot;
The equivalent of that hook, in Drupal 7, is hook_comment_insert(), which receives the comment object as unique parameter.
hook_comment(), &quot;validate&quot;
Unfortunately, in Drupal 7 there isn't hook_comment_validate(); you need to add a validation handler for the comment form.
function mymodule_form_comment_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  $form['#validate'][] = 'mymodule_comment_validate';
}

function mymodule_comment_validate($form, &amp;$form_state) {
  /**
   * Validate the comment.
   * $form_state['values']['name'] is the name of the user who wrote the comment;
   * $form_state['values']['is_anonymous'] is TRUE if the user is anonymous (not logged in);
   * $form_state['values']['mail'] is the email address of who wrote the comment;
   * $form_state['values']['homepage'] is the URL of the website of who wrote the comment;
   * $form_state['values']['subject'] is the title of the comment;
   * $form_state['values']['comment'] is the text of the comment;
   * $form_state['values']['language'] is the language associated with the comment;
   * $form_state['values']['uid'] is the user ID of who wrote the comment.
   * $form_state['comment'] is the comment object.
   */
}

Notice that mymodule_comment_validate() doesn't get any $comment parameter, and $form_state['comment'] is an object, not an array. You are using a $comment variable that is not defined, nor is one of the parameters.
The code I wrote works independently from the content type of the node where the comment appears. In Drupal 7, the hooks called to alter a form build from another module are hook_form_alter(), hook_form_BASE_FORM_ID_alter(), hook_form_FORM_ID_alter(). The base form ID for the comment form is &quot;comment_form.&quot;
If you just need to alter the comment form for a specific content type (e.g. the &quot;Article&quot; content type), then you replace mymodule_form_comment_form_alter() with mymodule_form_comment_node_article_form_alter().