Jump to content

Recommended Posts

Posted

Hey all,

I want to add users to the website (using the backend user page), and create a  specific user page for them automatically. That seems not to hard using hooks. 

But then I want to give them a link to the automatically generated page, so they can edit that page for themselves, and I don't really know a way to do it. 

Can someone help me out?

ps. The use case is an election page, where I can add a person, and the person can edit his own motivations. I only want to register the persons emailadress in processwire, and the person should be able to edit his information on his own page.

Posted

Hi 101Bram,

Welcome to ProcessWire! :)

So you somehow need to link one election page to one user account. Check out the Page field. On your user template, you can create a new Page field, let's name it "election". After creating the user and the corresponding election page, you can store the election page in this field. To create a link, you can simply use: $electionPage->url. Note that on your election template, you should check if the visiting user is equal to the user where the election page belongs to. If not, you can throw a 404 error.

As always with ProcessWire, this is just one way of doing it :)

Cheers

  • Like 3
Posted

Another way could be:

When automatically creating the userpage in your hook, you can set

wire('page')->created_users_id = wire('user')->id

Now the page is owned by that user.

When the user logs in to lets say .../userpages, in the template.php for userpages you can get the user's page with

$pages->get("template=userpagetemplate, created_users_id={$user->id}")

To be able to change the user of a page, you need to enable this in the template settings for the userpage-template in the Advanced tab towards the bottom.

  • Like 2

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.
×
×
  • Create New...