API / Minn\Login / LoginHooks

LoginHooks final readonly class

Minn\Login\LoginHooks · public/minn/src/Minn/Login/LoginHooks.php · 140 lines

The sign-in as plugins see it, when they are loaded. The credentials go through the reference's authenticate chain, so a plugin may refuse a sign-in (a breached password, a second factor, a locked account) or accept one the password alone would not; wp_login_failed is the chain's own report. wp_login follows a good sign-in and wp_logout a sign-out. The refusal is shown as the page's notices (LoginNotices): the chain's own as one vague sentence, a plugin's in its own words.

Constants and properties

privatereadonly Minn\Content\Users $users

Promoted from the constructor.

Public

new__construct(Minn\Content\Users $users)#
methodauthenticate(string $login, string $password): Minn\Content\UserRecord|WP_Error|null#

The credentials through wp_authenticate and the authenticate filters, as the reference's sign-in runs them: the user, or the refusal (a WP_Error, or null when the chain gave none).

methodsignedIn(Minn\Content\UserRecord $user): void#

After a good sign-in. The chain read the user through the runtime, which cached their meta before the new session was written, so the cache is let go first: a plugin reading session_tokens on wp_login (CleanTalk keeps the first session's address) must see the new one.

methodenter(string $action): void#

A sign-in page request arriving, as wp-login.php announces it: login_init, then login_form_{action}.

methodpage(string $action, string $title, string $siteName, string $homeUrl, ?Minn\Content\UserRecord $user = NULL, ?Minn\Login\LoginNotices $notices = NULL): array#

What plugins put on the sign-in page, where the reference's page puts it: the title (login_title), the head (login_enqueue_scripts, then login_head, which prints the styles and scripts), the body classes (login_body_class), the header's link and words (login_headerurl, login_headertext), the message above the form (login_message), the page's notices (login_errors, login_messages), the fields inside the form (login_form, lostpassword_form or resetpass_form, as the page is), and the footer (login_footer).

@return array{title: string, head: string, bodyClass: string, headerUrl: string, headerText: string, message: string, errors?: string, messages?: string, form: string, footer: string}
methodlanding(string $redirect, string $requested, Minn\Content\UserRecord|WP_Error|null $user): string#

Where a sign-in lands, as login_redirect says (the requested address beside it, and the user it found or why not).

methodleaving(string $redirect, string $requested, int $userId): string#

Where a sign-out lands, as logout_redirect says.

methodsignedOut(int $userId): void#

After a sign-out ended the session.

methodsignInFurniture(string $lostPasswordUrl): array#

What the sign-in page asks plugins about its own furniture, as the reference's page asks: the word beside Remember Me (login_remember_me_help_text), the lost-password link (lost_password_html_link), what stands between the page's links (login_link_separator), and whether the name field takes the focus (enable_login_autofocus).

@return array{rememberHelp: string, lostLink: string, separator: string, autofocus: bool}
methodlostPasswordPage(string $requested, WP_Error $errors): string#

The lost-password page's questions, as the reference's page asks them: what stands between its links, where the form sends a reader once the mail is out (lostpassword_redirect, kept in the form), and lost_password with the page's errors. Returns the address the form keeps.

methodpostPasswordExpiry(int $expires): int#

When a post password's cookie runs out (post_password_expires; 0 is when the browser closes).