This question has been answered by multiple community members. See the first response.
$key = 'color'; $searchTerm = 'red'; $profiles = $modx->getIterator('modUserProfile') foreach($profiles as $profile) { $extended = $profile->get('extended'); if ($extended[$key] == $searchTerm) { /* found one -- do something */ } }
// die ('Unauthorized Access');
$pFirstName = $modx->getOption('user_search_vorname', $_POST, ''); $pLastName = $modx->getOption('user_search_nachname', $_POST, ''); $pKeyWords = $modx->getOption('user_search_keywords', $_POST, ''); $pKeyWords2 = $modx->getOption('user_search_keywords2', $_POST, ''); $modx->setPlaceholder('user_search_vorname', $pFirstName); $modx->setPlaceholder('user_search_nachname', $pLastName); $modx->setPlaceholder('user_search_keywords', $pKeyWords); $modx->setPlaceholder('user_search_keywords2', $pKeyWords2); $fields = array(); if (isset($_POST['submit-var']) && $_POST['submit-var'] == 'etaoinshrdlu') { $fields['where'] = '{"vorname:=":"' . $pFirstName . '","OR:nachname:=":"' . $pLastName . '","OR:keywords:=":"' . $pKeyWords . '","OR:keywords2:=":"' . $pKeyWords2 . '"}'; $results = $modx->runSnippet('GetExtUsers', $fields); }
But my form/profile has additionally about 25 different text-inputs and some textareas, which I'd like to search at once. I don't understand how I can access all values of every field in my ext_user_data-table?
if (isset($_POST['submit-var']) && $_POST['submit-var'] == 'etaoinshrdlu') { $fields['where'] = '{"vorname:LIKE":"%' . $pFirstName . '%","OR:nachname:LIKE":"%' . $pLastName . '%","OR:keywords:LIKE":"%' . $pKeyWords . '%","OR:keywords2:LIKE":"%' . $pKeyWords2 . '%"}'; $results = $modx->runSnippet('GetExtUsers', $fields); }