suntrop Posted June 14, 2017 Share Posted June 14, 2017 I am wondering why this one <?php $tsubscribers = wire('users')->find('template=user'); foreach ($tsubscribers as $ts) { echo $ts->email . '<br>'; } ?> will include unpublished users as well. The docs say https://processwire.com/api/selectors/#access_control Pages with hidden or unpublished status will not appear in the results from database-querying selectors that can return multiple pages (i.e. functions that return the PageArray type). For instance $pages->find("..."), $page->children(), etc. The site is running PW 2.7.2 … is this only new to PW 3? I had all users unpublished and see them as unpublished in the back-end. But when selecting users via API the unpublished are included as well. I have to add status!=unpublished to opt them out. Link to comment Share on other sites More sharing options...
Robin S Posted June 14, 2017 Share Posted June 14, 2017 I guess $pages->find() and $users->find() behave differently. You could always use $pages->find() instead... $tsubscribers = wire('pages')->find('template=user'); Be aware that PW does not provide good support for unpublished users. Besides there being no built-in controls in the admin interface for unpublishing a user or saving the user in an unpublished state, there are other gotchas such as the password inputfield being forced to an uncollapsed and required state when editing an unpublished user with no possibility of preventing this via hook (for collapsed state anyway). I requested better support for unpublished users a while back. 1 Link to comment Share on other sites More sharing options...
suntrop Posted June 15, 2017 Author Share Posted June 15, 2017 Robin, thanks for that! Indeed this one works differently. It feels a bit off the road using the wire('pages') instead of wire('users), but that would work as expected. But again, this is quite against the "everything is a page" mantra in PW. However, I will include a status!=unpublished in the selectors. Thanks again! 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