This question has been answered by multiple community members. See the first response.
$email = $hook->getValue('email');
$whiteList = array_flip(array_map('trim', explode("\n", $modx->getChunk('whiteList'))));
return isset($whiteList[$email]);
<?php
$email = $hook->getValue('email');
$whiteList = array_flip(array_map('trim', explode("\n", $modx->getChunk('whiteList'))));
if ( isset($whiteList[$email]) ) {
return true;
} else {
$errorMsg = 'Sorry, you cannot register because this email address is not whitelisted.';
$hook->addError('email',$errorMsg);
return false;
}
$whiteList = array_map('trim', explode("\n", $modx->getChunk('whiteList')));
if (in_array($email, $whiteList)) {