views:

120

answers:

2

Hi, Is it possible & if so, how can I allow users to only create a certain number of pages. ie. When they sign up, only allow them to create one page? Does anyone know of any extensions that would allow that?

Thank you for any help, much appreciated!

+1  A: 

Off the top of my head, the following approach ought to work:

  1. Hook into the userCan event for the "edit" action, check the page's existence (i.e. $title->exists()) and if it doesn't, consult some stored count (see below), and if the decision reached is to disallow creation, set $result to false and return false to stop further hooks overriding the decision.
  2. Hook into the ArticleInsertComplete event and update some stored count to reflect that the user ($user) has created another page.

The decision in #1 can be expanded via additional logic to support multiple policies in conjunction with, e.g. automatic rights assignment; for example, to allow users to create more than one page after they've reached so-called "auto-confirmed" status, or to ignore the check for administrators or other users with specific rights.

Rob
A: 

I don't know what exactly you want to do, but I bet you want to let them make only user page or something? It might be simpler for you to just restrict their editing to a certain namespace, until they are added to some special group.

Some more info might help us answer the questions better. Do you also want to restrict their editing to the page they create?

Adrian Archer
Yes I have found an extension to only allow them to edit pages they've created, but I only want them to be able to make one article in the main namespace.
Then I think editing the code is your best bet. You could actually make an extension and publish it, if you want!
Adrian Archer