First of all, thanks for this excellent module.

I found a problem if using node limit for a node type in which form block is used for submissions. If the limit has been reached (in my test case, a 1 per 60 second interval), the submitter is blocked from even viewing the page containing the node add form block (in my case, the front page). It redirects to the node/add page, with the error "You can't create more content of type xyz".

So it appears that node limit somehow is evaluating the limit if the add node form is even being viewed, prior to actually even submitting the form?

This is a bit of a show stopper with form blocks. It would be ideal if the evaluation and limit error message only happened when attempting to submit the form. Is this something that's possible?

Comments

Having this same problem.

Again, show stopper.

For now I hacked the module to allow a quick check in the block PHP conditions.

Added to block...

<?php
global $user;
if(
_node_limitnumber_check($user,'content-type-here') ) return true;
?>

Added to module...

<?php
function _node_limitnumber_check($user, $type) {
    include_once(
'node_limitnumber.inc');
   
$limit = _get_limits_for_user($user, $type);
    if (!empty(
$limit)) { // We get the total number of nodes of this type owned by this user
     
$q = "SELECT * FROM {node} WHERE type = '%s' AND uid = %d";
     
$result= db_query($q, $type, $user->uid);
     
$num = db_affected_rows();
      if (
$num >= $limit) {// We have the data, now we check the limit
       
$nodetypename = node_get_types('name', $type);
       
drupal_set_message(t("You can't create more content of type !type, sorry.", array('!type' => $nodetypename)), 'error');
        return
false;
      }
      else return
true;
    }
    else return
true;
}
?>

What should really be done is to fix the drupal_goto('node/add'); line in the node_limitnumber_nodeapi() function to be smart enough to hide the block not just redirect to the node/add page

Status:Active» Closed (won't fix)

At this point, this issue is going to be marked as won't fix. This is either not in the direction of the project, or too out of the project scope.