Manaus Posted September 13, 2013 Share Posted September 13, 2013 Hello, I'd like to add the user who wrote the post to the page data (either guest, or the logged in user), this is the code I'm currently using $form = $modules->get('FormTemplateProcessor'); $form->template = $templates->get('annuncio'); // required $form->requiredFields = array('title', 'body'); $form->parent = $page->parent; // optional, saves form as page echo $form->render(); // draw form or process submitted form Btw, using this code I get all the fields I put in the template, so rendering the user field generates a dropdown selectable list of users... Thanks for any advice! Link to comment Share on other sites More sharing options...
ryan Posted September 15, 2013 Share Posted September 15, 2013 ProcessWire already keeps a references to the users that created the page and last modified the page, so you don't need to maintain that separately yourself. They are present in $page->created_users_id and $page->modified_users_id (to get the ID) or $page->createdUser and $page->modifiedUser to get the User objects. 1 Link to comment Share on other sites More sharing options...
Manaus Posted September 15, 2013 Author Share Posted September 15, 2013 Thanks Ryan! I'm wondering how to query the pages so to find all pages with user = loggeduser... I'm trying this one: $annunci = $pages->find("parent=/bacheca/, sort=-date, title!=new, limit=20, createdUser=$user->id"); But it doesn't seem to work. Thanks!! Link to comment Share on other sites More sharing options...
Soma Posted September 15, 2013 Share Posted September 15, 2013 $page->createdUser is a method to get the user object and has nothing to do with the field $page->created_users_id you can use in selectors. Link to comment Share on other sites More sharing options...
Manaus Posted September 15, 2013 Author Share Posted September 15, 2013 Oh I see now I'm starting to get a grip on this Thanks and sorry for the dumbness 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