if ($user = $modx->getObject('modUser', array('username'=> 'user1'))){ //do something with existing user return "already exists !"; }
if ($user = $modx->getObject('modUser', array('email'=> '[email protected]'))){ //do something with existing user return "already exists !"; }
$profile = $user->getOne('Profile'); $email = $profile->get('email');
The email is in the profile object
$profile = $user->getOne('Profile'); $email = $profile->get('email');
<?php /*********************************************** * Snippet: xvRegCheckEmail * * Check if email exists * usage : * &validate=`email:xvRegCheck=[[+email]]` * &customValidators=`xvRegCheckEmail` */ $value_tocheck = $scriptProperties['value']; $value_tocheck = $modx->quote($value_tocheck); //return $value_tocheck;//la valeur du champ $sql = "SELECT * FROM modx_user_attributes WHERE email = $value_tocheck";//ok foreach ($modx->query($sql) as $row) { // do something if email exists $result .= $row['id'] .'<br/>'; } if($result){ //$output = "There is already a user with this email !" .$field_tocheck. " = " . $value_tocheck . " !"; //$output = "1"; return 'There is already a user with this email ! <a href="[[~471]]?e='.$value_tocheck.'" target="_blank"><i class="fa fa-question-circle" aria-hidden="true"></i></a>'; } return true;
$result = $modx->getObject('modUserProfile', array('email' => $value_tocheck)); if ($result) { // etc. }