FieldtypePassword
Stores a hashed and salted password
The value is always a Password object — the raw hash is
never exposed. Setting a new password is done by assigning a plain-text string.
Password object. The Password class provides:
$field->pass(write-only) — set a new plain-text password$field->hash— the stored hash (read-only)$field->matches('plain')— verify a plain-text password against the stored hash
// Set a new password
$user->pass = 'NewSecurePassword123!';
$user->save('pass');
// Verify a password
if($user->pass->matches('enteredPassword')) {
// correct password
}
// Check if a password has been set
if($user->pass->hash) {
// password is set
}Do not read $user->pass and re-assign it — doing so may corrupt or double-hash the stored value.
Password fields cannot be used in selectors. The hash is not searchable and the plain-text value is never stored.
- The password is hashed using bcrypt. The plain-text value is never stored.
- No compatible fieldtypes (password cannot be converted to another type).
- Database columns:
char(40)for hash,char(32)for salt.
Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the Fieldtype class also inherits all the methods and properties of: Fieldtype, WireData and Wire.
Common
Additional methods and properties
In addition to the methods and properties above, Fieldtype
API reference based on ProcessWire core version 3.0.261