Jump to content

Creating a page when a user registers

Recommended Posts


I'm creating a site where people can vote on dogs.

To start with, I need the dog owners to register and then upload text, images, and videos about their dog. What I thought I could do is to create a page when the user registers. The page would be unique by using the member ID. So I would end up with:

     - Members

Then each member page would have 1 or more children which would be the dogs that they have added.

I just wanted to ask if that is a good way of doing things or if there's maybe a much simpler way of doing this.

Thanks in advance for any advice.

Share this post

Link to post
Share on other sites

I would probably prefer to put my users under the Members page directly. That way you would still end up with your suggested page tree, but those pages would actually be the users and there would be no need to maintain a relationship between users and their pages. Have a look at this blog post for a tutorial: https://processwire.com/blog/posts/processwire-core-updates-2.5.14/#multiple-templates-or-parents-for-users

  • Like 7
  • Thanks 1

Share this post

Link to post
Share on other sites

Thank you @Jan Romero. For some reason, when I'm adding a new user now, I get '/processwire/access/users/' as the only option for the parent. Have I forgotten something?

Share this post

Link to post
Share on other sites

Hm, have you set the corresponding “allowed templates for children” and “allowed templates for parents” options in the templates’ family tabs?

Share this post

Link to post
Share on other sites

I think I've done that correctly. Please see attached.

user_1 has an id of 57.
owners has an id of 58.

So I've added

$config->userTemplateIDs = array(3, 57);
$config->usersPageIDs = array(29, 58);

to config.php.




Share this post

Link to post
Share on other sites
12 hours ago, Dean said:

owners has an id of 58.

$config->usersPageIDs = array(29, 58);

I think this may be the problem. 58 seems to be the ID of your template, but the config setting must be supplied with the ID of the page. In your example from the opening post, that page is “Members”, so you want to change Members’ template to owners (58) and put Members’ ID into $config->usersPageIDs. It’s probably a four digit number rather than a double digit template ID.

  • Like 3

Share this post

Link to post
Share on other sites

Brilliant! That was it. Thank you so much @Jan Romero.


Share this post

Link to post
Share on other sites

Sorry, one last question. How can I now create my new user with the new template and new parent? It doesn't seem to like this:

wire()->addHookBefore('LoginRegister::createdUser', function($event) {
	$u = $event->arguments[0];
	$u->parent = 1083; // set new parent


Share this post

Link to post
Share on other sites

Uh, I’ve never used LoginRegister, but some pointers:

  • Not sure if you can use the hook arguments that way. I always use $event->arguments(0) (it’s a method).
  • You should probably hook createUserReady instead. This fires immediately before the user is saved, so you don’t need to do it.
  • You aren’t setting the user’s template to 57.


  • Like 1

Share this post

Link to post
Share on other sites

Thanks once more @Jan Romero. It is now creating a user under /members/.

Just to clear things up, is what it has created under /members/ a page or a user? Or both? 🤪

Share this post

Link to post
Share on other sites

It’s both! A user is a special kind of page. If you look at ProcessWire’s source code, you will see that the User class extends the Page class. At first it’s a little confusing, but it’s pretty cool because you roughly always deal with the same (or quite similar) things in PW. For example, you can find users using selectors just like finding pages of content. You can also modify and save them the same way, as you did in your hook. And if you want to add a field to your user (maybe a profile picture) you know just what to do: create a field and add it to the template, just like any other content.

  • Like 2

Share this post

Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By franciccio-ITALIANO
      Hi, I need to provide a quite complex user registration form: description, subdescription, drop-down lists etc. 
      Through this registration, users will be able to access and comment.
      If someone responds to their comments, I would like a NOTIFICATION to appear when accessing their panel.
      My social interaction project is just that, it seems simple, I don't need more.
      Now I am undecided whether to use buddypress, elgg, or a native processwire system.
      What do you recommend? 
      If you recommend processwire, which modules should I install?
      Do they work or is processwire too immature for that?
      Translated with www.DeepL.com/Translator (free version)
    • By ridgedale
      Reference: PW 3.0.111 and uikit3 based site using the Regular-Master profile.
      Despite my searches of the forum I'm somewhat confused about how to create new child pages on the frontend when a user clicks on a button on the parent page. I also have an equivalent button that is intended for uploading a .csv file to automatically create multiple new pages. This basically relates to a club (parent) and members (child) template configuration. Hopefully this explanation makes sense.
      A button should be able to launch the code needed to initiate the script required to create a new page using something like:
      <a href="/path/page.php">New +</a> <a href="/path/page.php">New ++</a> Does the code to create the new page or new pages need to be run from the template file for the child or the parent?
      A new individual member page will need to be editable manually at the point of page creation as well as subsequently, whereas multiple new pages will need to be editable after they have created and populated with data, again, as well as subsequently.
      I would very grateful for any advice or pointers as to how to achieve this.
    • By LukeCage
      Hi! I have a big problem with a client of mine. I have to do something that i don't do very often with processwire, and i'm very afraid that i'm not gonna able to do it. So i write to search some help from you experts.
      The website that i'm gonna create will have a database with infos about users. This users are not the actual registrered users, but possible users. I'll try my best to explain this. What i will have is a datasheet in the database with infos about all the users (name, surname, fiscal Code) that can register to the website. So during registration the website is confront with this database of people, and accept or not your registration to the website.
      Now. The problems are: the client need a page in the CMS to insert this people in the first place (Custom Admin Page?) in the database. I read what i need to create it, but i don't understand what i need to do next. What i need to do for reading and writing to the database, with data, directly from a custom admin page in processwire?
      The other thing is. I can do this control during registration? I Can extend fields in the user account?
      I'm completely in your hands.
    • By ziu
      Hi everyone,
      I am new to processwire, but really  appreciate the way  its works. Thank you Ryan.
      I need your help guys, any help would be  appreciated, as i am searching the forum since last 1 month. but couldn't found out how to achieve.
      My issue is as my user registers on my website, it will be assigned a role. eg  Register
      but what i want to achieve is that after login i want  user to have edit profile , logout and Add Page. But i want user to add only one time, only single page can be post by him.
      if user adds the page, and login into  account it must show edit page.
      Please help me guys.
  • Create New...