Lars282 Posted June 9, 2012 Share Posted June 9, 2012 Hey! I am not sure, probably this has been discussed somewhere already, but I could not find anything. I have a website where users once registered and logged in should be able to view and post content (in the form of a PW page with a certain template, like adding a page in the admin). I have two questions concerning this. Firstly, how can I add a page using a form on a website to add pages to the page tree? Secondly, I am not sure whether I can use the PW users for this. I need visitors to be able to register themselves, maybe with approval needed from an admin before they can login (already found how to have a custom login page). I might need to store more information than possible in the current user page, i.e. more than the name/pw/email - would that work? If so, how? Many thanks, Lars Link to comment Share on other sites More sharing options...
Soma Posted June 9, 2012 Share Posted June 9, 2012 Go on templates, filter to show "system" templates, edit user template. 1 Link to comment Share on other sites More sharing options...
teppo Posted June 9, 2012 Share Posted June 9, 2012 Hello there! I'd consider adding a role with very few privileges (basically only page view access), name it "unapproved" or something like that. The register form could create new users via the API and assign that non-privileged role to them. After that an admin could check their info and assign whatever role they actually need. You can find many posts about creating forms from the forum and creating new users is instructed in the API documentation: http://processwire.c...variables/user/. Also, here's some discussion about adding extra information for users: http://processwire.c...extending +user. You could also edit the user template like @Soma suggested above -- not really sure which is the "correct way" here.. 1 Link to comment Share on other sites More sharing options...
Lars282 Posted June 9, 2012 Author Share Posted June 9, 2012 Thanks! Didn't even notice the template filter until now! Ok - I will have a look and decide which method to use, but seems both straight forward. Is there a brief example on how to use $page->save()? Does it work similar as for user, just using $page? <?php $u = new User(); $u->name = "gonzo"; $u->pass = "BamBam!"; $u->addRole("guest"); $u->save(); Thanks, Lars Link to comment Share on other sites More sharing options...
teppo Posted June 9, 2012 Share Posted June 9, 2012 @Lars282, syntax for adding pages is pretty much the same as with users, with some extra params to consider (such as template.) You can find more information here: http://processwire.c...ariables/pages/, under "Examples of saving and deleting pages". Link to comment Share on other sites More sharing options...
Soma Posted June 9, 2012 Share Posted June 9, 2012 Hello there! I'd consider adding a role with very few privileges (basically only page view access), name it "unapproved" or something like that. The register form could create new users via the API and assign that non-privileged role to them. After that an admin could check their info and assign whatever role they actually need. The prefered, simpler way is to make the user when created via API unpublished: $user->addStatus(Page::statusUnpublished); See cheatsheet addStatus Then the user can't login yet. And the admin can just go and publish the user (same as with pages) in the admin. Users are pages so the page API applies here same way as it is for pages. Or using API to publish $user->removeStatus(Page::statusUnpublished); See cheatsheet removeStatus The different system flags are also on the cheatsheet. 6 Link to comment Share on other sites More sharing options...
Lars282 Posted June 9, 2012 Author Share Posted June 9, 2012 Thanks all, this helps a lot! @Soma, is there a preferred way of adding more content to a user? Ie adding child pages or changing the template? Link to comment Share on other sites More sharing options...
ryan Posted June 11, 2012 Share Posted June 11, 2012 If the content you want to add consists of fields that would be applicable all users, then it's preferable to add them directly to the user template. But if it's content that is only going to be applicable to some users, then may be better to make them child pages. 2 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now