Jump to content

Using a selector, how do I find a page created by a specific user?


Recommended Posts

Posted

What is the difference between $pages->find() and $pages->get() ? They both look the same to me. Is ->get() for finding an individual page whereas find->() is for more than one?

Also how do I find a page using a selector based on which user created the page? I couldn't find anything under Selectors documentation on how to do it.

Posted

Find gives you multiple pages (actually a PageArray with zero or more pages) , and respects page status, whether it's hidden and access settings, while get gives you the page (a Page/NullPage object) disregarding access preferences. 

To find pages created by a particular user, you need

$myUser = $users->get('admin');
$myPages = $pages->find("created_users_id=$myUser");

 

  • Like 3
Posted
1 hour ago, desbest said:

What is the difference between $pages->find() and $pages->get() ?

More info from the Docs

Get: http://processwire.com/api/ref/pages/get/

Find: http://processwire.com/api/ref/pages/find/

  • 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...