This is a great module and something I was just looking for. It works very nicely, except for one small bug. I allowed a role to create only 1 node of a certain content type, but as soon as I submit that first node, the "You can't create more content of type Company, sorry." message is shown. The node is still created, by the way. I would expect this message to be shown only when the user tries to create another node of the same type - which does happen.

Comments

nachenko’s picture

It seems that i should check the condition for the error message to be shown.

This message appears given certain conditions in hook_nodeapi(). One of them is "$op == 'insert'". I think the problem is there.

I can't check it now, but i'll fix it.

davemybes’s picture

Hi nachenko,

Yeah, I thought it might have something to do with $op == insert, but I couldn't figure out how to get around it. Maybe another check to see if the node has just been created?

nachenko’s picture

'insert' condition is just a safety measure, just to avoid people trying to 'cheat' the system by generating themselves a proper $_POST object.

Perhaps this should be verified in a separated piece of code to fine-tune the error conditions. I'll try to check it tomorrow.

But this also mean that the hook_nodeapi $op == 'insert' is being fired AFTER the node being inserted, so it's not doing it's job. Need an alternate solution for this.

But hey! Thanks a lot for the test. As d.org gives no statistics about download, I was wondering myself "will anyone bother about this?" It's good to see someone cares.

davemybes’s picture

I definitely care :) I am building a couple of sites where a user must only be able to construct one node of a particular content type, and I have been looking into using nodeprofile, as it has the node limit thing, but its linked to the user profile, and is fairly complex. Your module came in at just the right moment, and if one person is going to use it, you can bet there are more.

About $op == insert, after I posted I thought a bit more and almost dismissed it as the problem. I just assumed that it fired in the correct place, so wouldn't be called for a second check. But maybe you're right, and that nodeapi function of yours is getting called twice. Either $op == insert has a bug, or our understanding of when it fires is incorrect.

I just did a test and removed the $op == insert option, and the error does not appear. So its definitely the culprit somehow. Module seems to work fine without it in.

muhleder’s picture

I'm using this as well, it's prefect for allowing users to create a profile page.

I've upgraded to the 5.x-1.1 release and I'm still getting the 'You can't create more content of type Artist Page, sorry.' message.

I couldn't find the "$op == 'insert'" line in the code to remove, whereabouts is it so I can try that?

Strangely for me the page is redirected from /node/1/edit to /node/add when I try to edit a page. Not sure if this is by design or not.

For the moment I'm setting the limit to be one more than I need in order to enable editing.

davemybes’s picture

muhleder, the $op == insert check has been removed in 1.1 in an effort to get rid of the error message. And the error is now gone, so I guess this issue could be marked as fixed.

I'm going to open a new issue for the "Cannot edit" problem as they are not caused by the same thing. See http://drupal.org/node/249906.

nachenko’s picture

Status: Active » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.