Limit the reviews on "Product" content type I want to limit the users' review of my "Product" content type to only one, and I tried to implement a code from this link in Drupal 7 as a simple module named "review_limit." I saw this module in my module list and installed it without an error.

This is my code:

function review_limit_form_alter($form_id, &amp;$form) {
    // If the form is a "product_review" node form
    if ($form_id == 'product_review_node_form') {
        // Add an extra validation function //
        $form['#validate'][] = 'review_limit_user_node_limit';
    }
}

// Validation function
function review_limit_user_node_limit($node) {
    // Get our logged in user's details
    global $user;
    $result = db_query("SELECT n.uid, n.nid
    FROM {field_data_field_product_review_pr}
    Inner Join {node} n ON field_data_field_product_review_pr.entity_id = :nid
    Inner Join {users} ON n.uid = :uid", array(':nid' =&gt; $node-&gt;nid,':uid' =&gt; $user-&gt;uid))-&gt;fetchfield();
    //if founded referenced field from the logged user, drupal show error message
    if ($result) {
        // Throw error
        //drupal_set_message('You have already submitted a review of this item.', 'error');
        form_error($element['title'], t('You have already submitted a review of this item.'));
        die;
    }
}


and i have prepare a template named product--review.tpl.php, page--node--add--product_review.tpl.php and call it from my template.php using

function bartik_theme() {
  return array(
    'product-review_node_form' =&gt; array(
      'arguments' =&gt; array(
          'form' =&gt; NULL,
      ),
      'template' =&gt; 'product_review-node-form',
      'render element' =&gt; 'form',
    ),
  );
}


This module does not work, every user is still can to create a product review node as much as they want.
Did I miss anything? Can anyone help me to solve this problem?
The error is that you use die; the hook should simply return to the calling function. If you use die, you are avoiding that the code calling the validation handler is called back, which means the code that checks if there are any validation errors, and shows them to the users is never executed. 

If you look at the code used by a Drupal validation handler, such as user_pass_validate(), you will notice it doesn't use die, which is never used from any form validation handler.

function user_pass_validate($form, &amp;$form_state) {
  $name = trim($form_state['values']['name']);
  // Try to load by email.
  $users = user_load_multiple(array(), array('mail' =&gt; $name, 'status' =&gt; '1'));
  $account = reset($users);
  if (!$account) {
    // No success, try to load by name.
    $users = user_load_multiple(array(), array('name' =&gt; $name, 'status' =&gt; '1'));
    $account = reset($users);
  }
  if (isset($account-&gt;uid)) {
    form_set_value(array('#parents' =&gt; array('account')), $account, $form_state);
  }
  else {
    form_set_error('name', t('Sorry, %name is not recognized as a user name or an e-mail address.', array('%name' =&gt; $name)));
  }
}