buten/module-guest-restriction

Magento 2 module that restricts access or visibility for guest users.

Installs: 1

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

Type:magento2-module

pkg:composer/buten/module-guest-restriction

1.0.0 2025-10-30 14:17 UTC

This package is not auto-updated.

Last update: 2025-10-30 17:59:03 UTC


README

Buten_GuestRestriction is a lightweight Magento 2 module designed to restrict access and hide specific frontend content for guest (not logged-in) users.
It helps store owners ensure that certain features, blocks, or pages are visible only to authenticated customers - improving user flow and protecting restricted content.

🧩 Features

  • 🚫 Hide or disable layout blocks for guest users.
  • βš™οΈ Configurable from the Magento Admin panel.
  • 🧩 Compatible with both Magento Open Source and Adobe Commerce.
  • 🧩 Lightweight - no database schema changes or UI components added.

πŸ—οΈ Module Structure

Buten/GuestRestriction
β”œβ”€β”€ etc/
β”‚   β”œβ”€β”€ adminhtml/system.xml       # Admin configuration settings
β”‚   β”œβ”€β”€ config.xml                 # Default configuration values
β”‚   β”œβ”€β”€ frontend/di.xml            # Dependency Injection for frontend
β”‚   β”œβ”€β”€ frontend/events.xml        # Observers for frontend area
β”‚   └── module.xml                 # Module declaration
β”œβ”€β”€ Helper/ConfigHelper.php        # Fetch configuration values
β”œβ”€β”€ Observer/RemoveBlocksObserver.php # Removes restricted blocks for guests
β”œβ”€β”€ Plugin/RestrictPlugin.php      # Plugin logic for restriction
β”œβ”€β”€ registration.php               # Registers the module with Magento

βš™οΈ Installation

Option 1: Install via Composer (recommended)

If the module is published on Packagist or your VCS repository:

composer require buten/module-guest-restriction
bin/magento module:enable Buten_GuestRestriction
bin/magento setup:upgrade
bin/magento cache:flush

Option 2: Manual installation

  1. Copy this module to:
    app/code/Buten/GuestRestriction
    
  2. Enable and upgrade:
    bin/magento module:enable Buten_GuestRestriction
    bin/magento setup:upgrade
    bin/magento cache:flush

πŸ”§ Configuration

Navigate to:

Admin Panel β†’ Stores β†’ Settings β†’ Configuration β†’ Buten β†’ Guest Restriction

*Select scope if required.

Available Settings

Setting Description
Enabled Turn guest restriction on or off (redirects guests to the login page)
Allowed pages Specify the list of pages allowed for guests
Remove blocks (Optional) Turn blocks removal on or off
Blocks to be removed (Optional) Specify the list of block names to be removed

🧩 Compatibility

Magento Version Supported
Magento Open Source >= 2.4.4 βœ…
Adobe Commerce >= 2.4.4 βœ…
PHP >= 8.1 βœ…

🧩 Technical Details

  • Area: Frontend only
  • Depends on: Magento_Customer, Magento_Store
  • Entry Points: Observers & Plugins
  • Data Storage: Uses configuration only (no DB tables)

πŸ‘¨β€πŸ’» Developer

Author: Pavlo Butenko
GitHub: https://github.com/pbuten
Email: pavlo.buten@gmail.com

If you find this module useful, please ⭐ star the repository!

πŸ“„ License

This module is licensed under the MIT License.
You’re free to use, modify, and distribute it in commercial or open-source projects as long as you retain the copyright notice.