This is the code I am using for Drupal 6:
/**
* @Implement of hook_nodeapi()
*/
function mycaptcha_nodeapi(&$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->mycaptcha_ask) {
mycaptcha_ask_form_validate($node->mycaptcha_ask);
}
break;
}
}
/**
* @Implement of hook_comment()
*/
function mycaptcha_comment(&$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(&$form, &$form_state, $form_id) {
global $user;
$form['#validate'][] = 'mycaptcha_comment_validate';
}
function mycaptcha_comment_validate($form, &$form_state) {
global $user;
if ($comment['mycaptcha_ask']) {
mycaptcha_ask_form_validate($comment['mycaptcha_ask']);
}
}