leftblank Posted January 10, 2014 Share Posted January 10, 2014 Hi, How can I display which user published a page? Looking at the cheatsheet, the $page variable doesn't seem to have any field containing an associated user object. It seems like this should be possible out of the box, so am I missing something, or this something I'd have to implement manually? Many thanks! Link to comment Share on other sites More sharing options...
Martijn Geerts Posted January 10, 2014 Share Posted January 10, 2014 (edited) sorry, didn't read well enough. $page->createdUser // The user that created this page. Returns a User or a NullUser. $page->modifiedUser // The user that last modified this page. Returns a User or a NullUser. The User class is extending Page, loads of things you can do with a page, you can do with a User. You can find these things in: http://cheatsheet.processwire.com/, actually the explanation is a copy/paste Changed this post... Edited January 10, 2014 by Martijn Geerts 3 Link to comment Share on other sites More sharing options...
MatthewSchenker Posted January 10, 2014 Share Posted January 10, 2014 Greetings, It's built into all pages you create: $page->createdUser->name Thanks, Matthew 2 Link to comment Share on other sites More sharing options...
Joss Posted January 10, 2014 Share Posted January 10, 2014 If you do not want to display the "name" which is the user's Username, you can create a couple of extra fields (call them first_name and last_name, for example) and add them to the user template (On the setup > templates page chose to display the system templates by opening the filters) Now you can display $page->createdUser->first_name rather than expose the login user name. 3 Link to comment Share on other sites More sharing options...
leftblank Posted January 13, 2014 Author Share Posted January 13, 2014 Thanks guys - this community is the best. 1 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