Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top