i can’t seem to get that to work it’s just throwing up an Internal Server Error when i call that snippet on the page.
Paste your full snippet code in here. Maybe we can see a problem with it.
Let’s put in some quick and dirty sanity checks:
<?php
$zip = 'red';
$zipUsers = array();
/* get all active users */
$users = $modx->getCollection('modUser',array('active' => '1'));
if (! $users) {
return "No Users Found";
}
foreach ($users as $user) {
/* get the user's profile */
$profile = $user->getOne('Profile');
if (! $profile) {
return 'User ' . $user->get->('username') . ' has no profile';
{
$extendedFields = $profile->get('extended');
if (! $extendedFields) {
return 'Could not get extended fields for User: ' . $user->get->('username') ;
}
/* get the user's zip code */
$userZip = $extendedFields->get('color');
/* if the user has the zip code, add them to the array */
if ($userZip == $zip) {
$zipUsers[] = $user->get('username');
}
}
foreach($zipUsers as $zipUser) {
$output .= '<p>User: ' . $zipUser->get('username') . '</p>';
}
return $output;
Remember that anonymous users in the front end have no profile.