$user


User Properties

$user->email

Introduced in Version 2.0

Description

Get or set email address for this user.

Echoing the current user's email address:

echo $user->email;

Changing the user's email address and saving that change:

setOutputFormatting(false) is required when editing data in a user's fields.

$email = $sanitizer->email("myname@processwire.com"); // Returns blank if address is invalid
if (!empty($email)) {
    $item = $users->get('myname');
    $item->setOutputFormatting(false);
    $item->email = $email;
    $users->save($item);
} else {
    // Display an error because their email address was invalid
}
									

Related

Post Comment