__( 'Site name', 'all-in-one-utilities' ), 'username' => __( 'The new account\'s username', 'all-in-one-utilities' ), 'reset_url' => __( 'Link to set a password (needed for the account to be usable)', 'all-in-one-utilities' ), ); } /** * {@inheritDoc} */ public function register(): void { add_filter( 'wp_new_user_notification_email', array( $this, 'apply' ), 10, 3 ); } /** * Rewrite core's email. The set-password link only exists inside * core's own message, so it's read from there. * * @param array $email Core's email. * @param WP_User $user The new user. * @param string $blogname Site name. * @return array */ public function apply( $email, $user, $blogname ) { if ( ! $user instanceof WP_User ) { return $email; } $reset_url = ''; if ( isset( $email['message'] ) && preg_match( '#https?://\S+#', (string) $email['message'], $matches ) ) { $reset_url = $matches[0]; } return $this->rewrite( (array) $email, array( 'site_name' => (string) $blogname, 'username' => $user->user_login, 'reset_url' => $reset_url, ), array( 'user' => $user, 'blogname' => $blogname, ) ); } }