API / Minn\Runtime / UserWrites

UserWrites final class

Minn\Runtime\UserWrites · public/minn/src/Minn/Runtime/UserWrites.php · 354 lines

Accounts written as WordPress's user functions write them: an account made, changed (its row, profile meta and role, with the notices a changed password or email sends) and deleted (its posts deleted or handed on), a reset key issued, the lookups that guard a new account, and the cached rows let go; each step with the actions and filters the reference fires in its order.

Public

staticvalidUsername(mixed $username): bool#

Whether a username survives strict sanitising unchanged and is not empty (validate_username), as validate_username leaves it.

staticusernameExists(mixed $username): mixed#

The id of the account with the login (username_exists), or false, as username_exists leaves it.

staticemailExists(mixed $email): mixed#

The id of the account with the email (email_exists), or false, as email_exists leaves it.

staticisMember(mixed $userId = 0, mixed $blogId = 0): bool#

Whether the user (the signed-in one when none is named) belongs to the site (is_user_member_of_blog).

staticappPasswordsAvailable(): bool#

Whether the site offers application passwords (wp_is_application_passwords_available): over HTTPS or on a local site, as the filter leaves it.

staticappPasswordsAvailableFor(mixed $user): bool#

Whether a user may sign in by application password (wp_is_application_passwords_available_for_user): the site allows them, then the filter.

staticresetKey(mixed $user): mixed#

A fresh reset key (get_password_reset_key), its hash stored under the time it was issued through the account's save; the refusal when the account may not reset.

staticcreate(mixed $username, mixed $password, mixed $email = ''): mixed#

A new account (wp_create_user) from a login, password and email.

staticinsert(mixed $userdata): mixed#

An account made or changed (wp_insert_user): each field through its pre_user_ filter first, in the reference's order; its id, or the error saying why not.

staticupdate(mixed $userdata): mixed#

An account changed (wp_update_user): the stored account and its profile under the given fields, as the reference merges them, then the notices a changed password or email sends.

staticdelete(mixed $id, mixed $reassign = NULL): bool#

An account deleted (wp_delete_user): its posts deleted, or handed to the account named; each meta key removed with its own actions, then the row; false for an unknown account.

staticcleanCache(mixed $user): void#

A user's cached rows and meta let go (clean_user_cache), plugins told.

staticrow(mixed $user): ?Minn\Content\UserRecord#

An account's row from an id, a login, a user object, or an object with an ID.

Internals 5

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privateasArray(mixed $userdata): array#
@return array<string, mixed> the account's fields from an array, a plain object or a user object
privateinsertAccount(array $account, array $userdata): int#

A new account as the reference writes it: the row, wp_set_password, each profile meta added, the role, the caches let go, then user_register. A role given as false leaves the account without one for the caller to add.

$accountarray<string, mixed>
$userdataarray<string, mixed>
privatefilteredRow(array $account, array $userdata): array#

A new account's row through wp_pre_insert_user_data, as the reference hands it (the password hashed), and back.

$accountarray<string, mixed>
$userdataarray<string, mixed>
@return array<string, mixed>
privateupdateProfile(Minn\Objects\User $existing, array $userdata, array $resolved, array $given = array ( )): int#

The update half of wp_insert_user: the changed columns, the profile meta, the role.

$userdataarray<string, mixed>
$resolvedarray<string, mixed>
$givenarray<string, mixed>
privatechangeNotices(array $user, array $userdata): void#

The notices a user whose password or email address just changed is mailed, to the address they had.

$userarray<string, mixed>
$userdataarray<string, mixed>