snicco/wp-guests-only-middleware

v2.0.0-beta.9 2024-09-07 14:27 UTC

README

codecov Psalm Type-Coverage Psalm level PhpMetrics - Static Analysis PHP-Versions

Installation

composer require snicco/wp-guest-only-middleware

Usage

This middleware should be added on a per-route basis.

If a logged a user is logged in this middleware will try to redirect to a route named dashbaord if it exists. Otherwise, the user is redirect to the homepage.

Optionally, a custom redirect path can be set by passing middleware arguments.

// Assumes you have configured an alias for "guests-only" => WPGuestsOnly::class
// A logged-in user will now be redirected to /foo.
$configurator->get('route1', '/route1', SomeController::class)
             ->middleware('guests-only:/foo');

Contributing

This repository is a read-only split of the development repo of the Snicco project.

This is how you can contribute.

Reporting issues and sending pull requests

Please report issues in the Snicco monorepo.

Security

If you discover a security vulnerability, please follow our disclosure procedure.