We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38323
    • 26 Posts
    For our password reminder (Login Add-On) we need users to enter both their:

    username AND email-adress

    For security reasons we need users to enter them both. Obviously username and e-mailadres should match a single user en send this user his or her password-rest email.


    Tried to write a snippet to find a user by his/her email-adres AND his/her username, but this doesn't seem to work.

    $user1 = $modx->getObject('modUser',array('username' => 'username1'));
    $user2 = $modx->getObject('modUser',array('email' => '[email protected]')); <-- this doesn't work... 
    
    if ( $user1->get('id') ==  $user2->get('id') ) {
      okay!;
    }


    Anyone got suggestions?
      • 38323
      • 26 Posts
      Thanks to Mark Hamstra i got i fixed:

      $c = $modx->newQuery('modUser');
      $c->where(array(
          'username' => 'username',
      ));
      $users = $modx->getObject('modUser',$c);
      
      
      $c2 = $modx->newQuery('modUserProfile');
      $c2->where(array(
          'email' => '[email protected]',
      ));
      $users2 = $modx->user->getOne('Profile',$c2);
      
      
      if ($users->get('id') == $users2->get('id') ) {
        echo 'okay';
      }