Jump to content

Capturing which user publishes a page


leftblank
 Share

Recommended Posts

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

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 by Martijn Geerts
  • Like 3
Link to comment
Share on other sites

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.

  • Like 3
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...