Null value given when confirming email’s

Firstly, this isn’t an error, it’s a warning. If it’s causing a page crash rather than a logic bug, thats because you’re printing your error log to the screen, not logging it to a log file as you should be doing. Turning off display errors should fix this.

This still leaves you with the warning, and those are still bad. Notice in your code you take the POST vars, and escape them, but you don’t do any check on what the value is. E.g. the form fields might be empty, or ''/null and they’d still pass through.

I suggest you reverse the order of your check, you need to check if the email is set first, then if it’s empty, then, once you’ve verified that there is actually something to check against, do you check that it’s the correct format of an email. Right now you’re doing it in the opposite order.

edit: Just to clarify your code should do:

if email is not empty then
     if email is not valid
          error="..."
     else
         if email1 == email 2 then
             wp_update_user
         else
             error="..."

Check if the email is empty before doing anything with it.

What you’re actually doing is:

if email is not valid then <- oh dear, we haven't checked if email is set/empty, error/warning
    error="..."
else if email is not empty then < -- too late, we've already used the email value!
    if email1 == email2 then
        wp_update_user