By DexterMilo on
Hello,
I am new to drupal and drupal.org so please forgive me if this is posted odviously somewhere (searching was done though I am blind at times). I am wondering if there is a module or easy method that would allow me to limit the number of nodes a user can create (within a given role) of a certain node type.
Example: I want users to be able to login and add a listing style node but then I dont want them to be able to create a second one. I do want them to be able to edit the listing that they created.
Thank you and Have fun,
Comments
make your on module
I think this can only be done by creating your own module, extending existing nodetypes.
If you know PHP, it's not that difficult. You just need to go through the drupal node API:
http://drupaldocs.org/api/4.6/function/nodeapi_example_nodeapi
Good luck!
Thanks for the link
I figured it was probably going to take me getting my feet a bit wet but decided to try the forums :)
I'm very interested also
I would be very interested in this functionality and would like to hear from anyone who is working on it.
Thank you,
ae2005
Well, me to start...
Seeing as how I must have this functionality I am going to start working on getting something to work for this site I am working on.
I am not an all star coder (this is within my means) and I am also pretty new to drupal. My general inclination is to make a module that allows admin'ers to limit the amount a given role can post of each content type (or just whichever content type the admin'er wishes to limit).
Having not jumped into it yet I am just wondering if anybody has a suggestion or two so that I dont spend time finding out that I went the wrong direction.
Would it be better to have the controls on the roles page? Access controls (scary page already)? Content Types? Or should it be on a new page in the admin? Bah, I will just have to get cranking and see what happens.
Another generally related question is if people reccomend that I make a module to handle the listing nodes or if I should just use the flexinode module to create a content type. The listings will be in a number of categories and sub-categories and will require quite a number of fields (something like 20).
OR, should I just combine my two ideas and make a separate module that handles the listing nodes and their access? Personally this seems like a non-drupal and oldevilschool method.
Would it be better to have
Just create a new module with a settings page where one can
The module should implement the nodeapi hook and perhaps use 'validation' or 'form pre' to check whether the user's role has the permissions to "... whather the restriction is...".
Yet, I don't have a clue if it will work... but it might be that I need to make it myself.
I'll keep you informed.
to be more precise
I'm planning to write a module to restrict not the number of nodes, but the combined size of the attachments!
But, yeah, it can be combined of course!
First, I need to be sure there is nothing in the CVS yet.
Looking for the same solution
+1 myside i am looking for the same solution. I am not a programmer. I need this functionality for application forms where an user can fill only 2 forms(Different Appilications) and not more than it. And one of the form is not ediatble too.
After you finish the module, post it here, it would veryhelpful to me.
Thanks in advance.
Sunny
www.gleez.com
proof of concept
Find below the code for the noderestrict module. It's just a proof of concept. Post your comments and ideas.
With this module, you can only set 1 restriction rule (on the settings page). I guess, if you would like more 'rules', improving the module will be required using the database to store the restriction rules.
Installation:
- create a 'noderestrict' dir in modules
- copy paste the code above into 'noderestrict.module'
- enable the module (admin/modules)
- set your restriction (admin/settings/noderestrict)
- set restriction for specific role (admin/access)
Thank You
Thanks for the module, i'll give a try and post the outcome.
Sunny
www.gleez.com
Not working under drupal 4.6.5
It's not working for me, i followed your instructions created the module in a directory and enabled it and after configuring the admin settings and admin/access for noderestrict module.
I tried for a blog type - it shows the msg "You are restricted to create only 1 blogs" and user in that role still able to create the blog irrespective of the restriction.
the msg is appearing on the top of the Submit personal blog entry.
Thanks in advance
Sunny
www.gleez.com
it's ok
Well, ok, your report is exactly what I implemented. In order to test, I didn't block the form to appear.
Check the code where I commented //drupal_goto('path').
If you uncomment it and fill in a path name, it should work.
Or copy paste the version below.
Working well
Once again thank you, it's working well.
Sunny
www.gleez.com
Thank drupal
You should not thank me, but drupal! The real contributors are the ones that created this fabulous CMS.
Well said
Well Said. I believe a one word 'Thanks' to drupal is not the right way. Instead I express my regards to the Drupal and contributors in the form of helping the drupal & it's community. Anyway my heartful thanks to you and drupal contributors.
Sunny
www.gleez.com
Thanks.
Thanks for posting this, its a good start.
I get a cannot modify header error when i attempt to save the rule.
Am too tired to look at it right now. Will look at it in the morning.
4.6.x
I need to say the module is made for 4.6! Maybe thats the reason?
Limit how many nodes a user can create?
Remove the white space after this "?>" noderestrict.module
Apache is bandwidth limited, PHP is CPU limited, and MySQL is memory limited.
Will this work in D7
Will this module will work in drupal 7?
I have the same problem that you have solved by this module please reply
Varun Kr Pandey
Modules do not work between
Modules do not work between versions of Drupal, they are only good for the version they were made for.
Contact me to contract me for D7 -> D10/11 migrations.
how to copy
toemaz
thank you so much for making this so quickly. I'm sorry I have a simple question. I tried to copy the code. I simply used the mouse to highlight the text in your comment, did control c, then did control v in my wordprocessor (openoffice). It looked okay, but I lost all the line breaks, and it's one long wrapped line. I uploaded it as you said. I went to admin to enable it. I see a line called noderestrict. However, there is no description and no checkbox. (drupal 4.6, civicspace). Is it because I've lost the line spacing? Is it something else? Can you please tell me how to copy it so that the line spacing is retained? I'm happy to test it after I get it working.
thank you so much. sorry for the simple question.
ae2005
help
1. get someone to help you. I can't reproduce your problem.
2. I have no idea in what way the civicspace distro differs from drupal 4.6. But indeed, it might be related to your first problem.
Good luck.
even administrator is limited
Dear Toemaz,
someone on another thread explained I need to paste into a text editor, not a wordprocessor. I now have your mode up and working as described.
However, I was surprised to see that if I limit an user to 1 posting in the page category, then I myself as administrator is limited to 1. Was that your intention? Is there a way I can change it so that as administrator I can still make as many as I want? (I guess the simplest way is to use a flexinode. I've been reading that flexinodes slow the performance down so I was going to try to avoid flexinodes.)
Even if I used flexinodes I'd need 2 flexinodes. Example: if I want to limit a user to posting only one car ad for $50 I still don't want to limit the admin to only one post. (Say, the admin may be posting for people without web access.)
I will also look into generating a different error page that says "you have exceeded the number of posts you are allowed of this type" instead of a "page not found" error.
Thank you so much. Great work and so quickly! Really terrific.
ae2005
About his module
You have to goto the access control page to select which roles it applies to.
Oops
I think I forgot to implement the role based restriction: added user_access('restrict node access') in the if statement.
Here comes the new version
how to check is updated?
Dear Toemaz,
thank you so much for the quick response. I couldn't wait to try it and did. I uploaded the new code. However, every screen looks the same to me. (modules, access control, settings)
Sorry, some basic questions.
1) do I need to disable the module and then enable it for it to use the new file? anything I need to do?
2) which screen is supposed to look different? is it access control and settings?
3) which lines should I check to make sure the module file I'm loading on my server is the correct version and that my upload was done correctly?
thank you! I can't wait to have this.
ae2005
Euh, nothing will look
Euh, nothing will look different. Just overwrite, set the role you want to restrict (access) and that's it.
According to me, it should work: admin (the first user) will not have any restriction, just the roles you enable ''restrict node access'' for.
Good luck.
Dear Toemaz
thank you for your quick response. I have checked everything and unfortunately I still cannot get it to work. I've checked that my server file has the "user_access" phrase. I even unchecked noderestrict for everyone but my user_id 1 still cannot make more than the maximum number of posts. Right now I have max posts set as 2 for forums, noderestrict as unchecked for everyone, but my admin cannot make more forums.
I'd like to see if anyone else has my problem. can we post a new thread asking people to test this module? I know there's a lot of interest. Would you like to do the post, or would you like for me to do the post?
thank you very much for making a great module,
ae
tested
It seems I overlooked something. The access system is created to give permissions. The original module didn't grant a permission, it took one away: restrict node access. Since the first user gets all permissions, he was also restricted from node access. I didn't test it well enough.
So, the solution was to change it this way it becomes a permission: "unrestricted node access"
So change your access settings, and leave the roles that should be restricted unchecked.
Here is the new code.
I don't think we should start a new thread. Maybe later on, when this module will be enhanced.
Anyway, thx for testing. I wasn't doing a good job yesterday.
working!
Toemaz,
thanks very much for the quick response. sorry i got held up today.
1) congratulations! my user is now restricted and my admin use is not.
2) your line in access control says "unrestricted" so I checked admin user, which I believe is contrary to what you said. this way worked
3) I can only set one restriction at a time right? not knowing that, I set 2 restrictions. the second one apparently erased the first one. you may want to warn the admin
4) have you tested this using flexinode? i haven't
5) is it simple or difficult to redirect to a custom error page?
this is great! May I ask if you have many years of development experience? how much development experience do you think a person needs to pull out a module quickly like you've just done? and how much time spent studying the Drupal code?
I think this will be very popular
ae2005
A lot of questions ;-)
A lot of questions ;-)
According to me, the superuser (first user), has always unrestricted access. Your 'admin user' must be a role then, not? I guess you have several admins maintaining the website.
Yes, one restriction at this moment. If you want more than one, then we will need to work with a database. Isn't that difficult, but needs more scripting time. Warning the admin can be done in a readme file, I guess.
No, I didn't.
No, you can do it yourself: under settings, you have a textfield for settings the path to the error page. By default, it is set to 404,but of course, the admin should change it.
4 years of hobby programming: php/mysql
I heard about Drupal the first time on Fosdem 05 (26 of Feb). Since I am not a programmer by profession, it probably took myself some more time to figure out how Drupal works. But, I did the best thing one can do to learn about drupal. I printed the whole handbook (that time it was written for 4.5.2) and read it completely, even though I didn't understand everything. I didn't even know what 'blogging' was. Yes, I was really ignorant.
Second, I took the bookmark module and started refactoring it to something I wanted myself. By doing so, I learned about the hooks. That wasn't a big problem. But the bookmark module didn't implement nodeapi (like this noderestriction module). It's only after a while I figured out that I could hook on the drupal node system (not being a programmer, I miss sometimes some crucial skills to see through an API).
The biggest problem was learning how the theming system works. It is only after a while, I understood why theming should be really separated from the business logic.
Yet, I don't think I did a good/quick job. This module has very minor requirements. The real 'new' code is only 5 lines (nodeapi hook). And even then, I took me 3 versions before it was working (ok, I didn't tested well, bc I thought someone else would do it ;-)
See ya
CVS
I requested CVS access to store this module as a new project. It will be easier to follow up bugs/requests/etc...
Anyway, do you think the name 'noderestrict' is good enough?
Yes the name is ok
IMO the name is ok. Let's wait for other options too...
Sunny
www.gleez.com
quota
I'd suggest naming it quota or user_quota and be prepared to offer other criterion.
name
Dear Toemaz,
Thank you very much for your long and detailed answers. very helpful.
I don't think user quota would be an intuitive name. I would think it's to limit the max number of users.
noderestrict does sound like restricting users from nodes.
how about userpostquota?
I was shooting for something
I was shooting for something more generic so further related functionality could be incorporated later (such as maximum size of images uploaded for example).
Why not shoot for a larger scope?
my intention
Actually, what you are saying is actually something I was planning to make. Whether it is the max size of images or files, it doesn't matter.
But since you can come up with a lot of requirements (restrictions) , I feel like it will be pretty hard to make one module that fits all needs. Nevertheless, we can try.
My need: a restriction on the sum of all files per user. And I think I will use the attachment module for setting up my filesystem.
I imagined a module that was
I imagined a module that was 'pluggable' in the sense that it was well enough documented and laid out that addition of criteria would be a simple.
Developing separate module may be more appropriate -- binding them together in the future would be a possibility if anyone was seeking a more comprehensive node number, file/image size, post rate, etc. quota restrictions.
Anyhoo -- luck to all working on respective parts/modules.
max posts
interesting idea to broaden the scope. I thought of a name: max posts. (taking out word "user" since admins who are not user 1 can also be restricted.)
I'm not looking for something that limits total size of all posts. I'd think it may be better to have 2 or modules that can be bundled, or it could be too confusing to administer. but maybe there's a simple interface I haven't thought of.
I'm thinking of charging per post (kind of like a classified)
toemaz, thank you for explaining the process of how you learned drupal. printing out the dev manuals and reading them when I don't understand it is a great idea. I'll pick up a lot I can imagine.
thank you!
ae
payment integration
while we are putting a wish list here, what would be fabulous would be this:
it costs $25 per post (think classifieds)
the user get one post for every $25 s/he paid.
this would mean linking to some payment module (worldpay or something), i don't know, haven't researched it yet)
I know this might be more than what you were thinking of, but can't help to brainstorm!
thank you so much,
ae
I personally see this
I personally see this outside the scope I was envisioning partially because it will rely heavily on other modules.
Let's wait and see
Let's wait and see whatever may come up as new requests ...
interesting module
interesting module
cvs access
Hi toemaz,
thanks for contribs!
How can this feature be added to code?
Restrict node access based on points accumulated, see userpoints module node 25408.
Posting will be allowed based on number of points per userpoint module or as defined in settings.
I like the name 'noderestrict' as originally proposed.
did you get a chance to upload in CVS as planned?
Thanks, Darly
Apache is bandwidth limited, PHP is CPU limited, and MySQL is memory limited.
cvs access
I requested cvs access in december last year. My request was approved and I was about to get my login info etc. But since then, no reaction anymore.
I guess all the focus is put on the 4.7 release for the moment. So I just wait a bit longer.
The userpoints module is new to me but your request doesn't look to hard to implement. Anyway, can you give me some more details how you would like to see this working:
Should this work lineair
max # of nodes = # of userpoints
or more flexible like:
y = f(x) --> max # of nodes = f(userpoints)
cvs access
Hu toemaz,
sorry for the late response, I had a short trip and back now!
I think it is a good idea to post version 4.6 cvs now, then will post updated version 4.7 becomes when available.
more flexible would be best and allow for more scenarios.
Detailed is as follows:
------------------------
1. users earn points by using nodes (comments, votes, etc.), thru userpoint module.
2. users are restricted to use nodes (upload files, upload images, etc.) thru noderestrict module.
3. noderestrict will use accumulated user points to control use of nodes. users can use nodes based on number of points earned.
Thanks, Darly
Apache is bandwidth limited, PHP is CPU limited, and MySQL is memory limited.
You don't really need a
You don't really need a module for this... But it's still worth creating.
If you upgrade or downgrade userroles based on events in Drupal, you can take care of that..
For example, if John as 10 points, upgrade him to "blogger", and make sure user permissions allow "blogger" members to blog.
If John goes below 10 points downgrade him to "newbie" and make sure "newbies" cannot blog.
Marcel
http://01wholesale.com
http://businessletters.com
http://01FTP.COM
You don't really need a
How can one upgrade or downgrade userroles based on events in Drupal?
Thanks, Darly
Apache is bandwidth limited, PHP is CPU limited, and MySQL is memory limited.
Just modify the users's rid
Just modify the users's rid in the users_roles table.
For a new user:
I'll give a better example soon
Marcel
http://01wholesale.com
http://businessletters.com
Wish I had seen this post earlier
I too have created a module that limits the number of posts a user can make. Had I seen this post earlier, I probably wouldn't have. Mine works a bit differently, so thought I would post my module as a new thread so as not to confuse the two.
http://drupal.org/node/52582
Would really appreciate comments / feedback. Am happy to stop development of my module if folks think that is best.
Thanks
I've been working on my code
I've been working on my code for the bioesque module http://drupal.org/node/52582, trying out this code, reading all the comments on both posts, reviewing other modules implementing similar ideas (bio.module at http://drupal.org/node/46589 and usernodes.module at http://drupal.org/node/50850). There are a lot of great ideas in all of them.
So I decided to take a stab a something new that would incorporate most of the features of them all and some of the feature requests and still leave room for further developement. It's called nodelimit module, please check out the code at http://drupal.org/node/55747 I would really appreciate any comments and input.
Thanks
Randall
User Quota module
Hi,
I've found this discussion about users having qutoas, and just thought I'd mention that I am working on a module that will enforce user posting quotas. It can be found at:
http://drupal.org/project/user_quota
The project isn't quite done yet, but I expect to have something of Beta quality later this week.
I also have some future enhancements in mind, such as the ability to integrate with other modules so that quota services can be provided to them too.
Cheers,
-- Doug
User_quota and Organic Groups
Hi,
I'm thinking of installing user_quota (UQ). However, my site (4.7.6) uses organic groups (OG).
I know that OG does not play well with any other node access mechanisms, so I'm wondering if UQ works with OG. Does anyone has UQ and OG installed and working?
Thanks.
http://drupal.org/project/nod
http://drupal.org/project/nodefamily gives this solution.
Try
Try www.drupal.org/project/nodefamily module. There is an option to limit a number of nodes per user. It has many other features as well.
----------------
Regards,
Dmitry Kresin, ARDAS group - Web site development, Drupal services, Software development, IT outsourcing.