Jump to content

each user allowed to add only one page under a parent template


ziu
 Share

Recommended Posts

You will need to use a hook, maybe in ready.php. Here's some code to get u started (unstested and written in a hurry).

// I can't remember if 'child' will get unpublished and/or hidden pages
// you might need to perform other checks (user logged in? => $user->isLoggedin())
$usersChildPage = $parentPage->child("created_users_id={$user->id}");
if($usersChildPage && $usersChildPage->id) {
	// this user already has a child page; do something else
}

 

  • Like 1
Link to comment
Share on other sites

Another approach is to not allow users to create pages at all, but rather automatically create a single unpublished page for each user in a hook at the time the user is created. Then each user can populate and publish their page if they wish.

  • Like 4
  • Thanks 1
Link to comment
Share on other sites

1 hour ago, Robin S said:

Another approach is to not allow users to create pages at all, but rather automatically create a single unpublished page for each user in a hook at the time the user is created. Then each user can populate and publish their page if they wish.

Yeah, this approach is better. 

@ziu

There's various examples in the forum regarding Robin's suggested approach. Just can't find them now.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...