Conditional for user registration fields What’s the best way to validate a user registration form to make sure that at least one of two fields is not empty? 

I’ve tried a very simple controller but can’t get this to work past the point of trying to save the user. Any pointers with this method or for a different method entirely?

public function actionIndex() {

    $this-&gt;requirePostRequest();

    $fields = craft()-&gt;request-&gt;getPost('fields');

    $customField1 = $fields['customField1'];
    $customField2 = $fields['customField2'];

    $user = new UserModel();
    $user-&gt;email = craft()-&gt;request-&gt;getPost('email');
    $user-&gt;password = craft()-&gt;request-&gt;getPost('password');
    $user-&gt;setContentFromPost('fields');

    if ($customField1 != '' || $customField2 != '') {

        // RETURN CUSTOM ERROR

    }

    // OTHERWISE SUBMIT USER REGISTRATION REQUEST 
    // AND RETURN ANY ERRORS

    craft()-&gt;users-&gt;saveUser($user);
    $this-&gt;redirectToPostedUrl();

}
Looks like I needed to set $user-&gt;username = craft()-&gt;request-&gt;getPost('email'); for my attempt to work.