Updated with the following:

1) Added die statement
2) Added $plainPassword =  ... before the if statement
3) Changed if (!user) to (!plainPassword)