PHPackages                             log1x/sage-password-protected - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. log1x/sage-password-protected

AbandonedArchivedPackage[Templating &amp; Views](/categories/templating)

log1x/sage-password-protected
=============================

A simple password protection package for Roots Sage customizable with filters.

v1.0.1(7y ago)171103MITPHPPHP &gt;=7.0

Since Oct 20Pushed 2y ago1 watchersCompare

[ Source](https://github.com/Log1x/sage-password-protected)[ Packagist](https://packagist.org/packages/log1x/sage-password-protected)[ Docs](https://github.com/log1x/sage-password-protected)[ RSS](/packages/log1x-sage-password-protected/feed)WikiDiscussions master Synced yesterday

READMEChangelog (2)Dependencies (1)Versions (4)Used By (0)

Sage Password Protected
=======================

[](#sage-password-protected)

[![Latest Stable Version](https://camo.githubusercontent.com/7af26810334c86d9f7ef26b1a34fe98268910b591ce32262ca71e57448e62b0b/68747470733a2f2f706f7365722e707567782e6f72672f6c6f6731782f736167652d70617373776f72642d70726f7465637465642f762f737461626c65)](https://packagist.org/packages/log1x/sage-password-protected) [![Total Downloads](https://camo.githubusercontent.com/8adfa6fc0ee988c92656a0edd9060864330ffcb01c94e03cd41ff603ba7153b5/68747470733a2f2f706f7365722e707567782e6f72672f6c6f6731782f736167652d70617373776f72642d70726f7465637465642f646f776e6c6f616473)](https://packagist.org/packages/log1x/sage-password-protected)

Sage Password Protected is a simple password protection package for use with [Sage 9](https://github.com/roots/sage) built for developers. No admin pages, no styles, no javascript, no bloat. Simply pass your own configuration to the provided filters and off you go.

Easily build your own field group for it within your theme options using ACF, or pass a filter so it is only enabled when `WP_ENV` does not equal `production`.

Requirements
------------

[](#requirements)

- [Sage](https://github.com/roots/sage) &gt;= 9.0
- [PHP](https://secure.php.net/manual/en/install.php) &gt;= 7.0
- [Composer](https://getcomposer.org/download/)

Installation
------------

[](#installation)

Install via Composer:

```
composer require log1x/sage-password-protected
```

Usage
-----

[](#usage)

Out of the box, this package does absolutely nothing as all values are defaulted to false. To get started, begin passing your values in an array through the provided filter. When passing the password, you must either pass it through `password_hash()` or if using ACF, use my [acf-encrypted-password](https://github.com/log1x/acf-encrypted-password) field.

### Configuration

[](#configuration)

#### Defaults

[](#defaults)

Below are the default / possible configuration values.

```
/**
 * Default configuration for Sage Password Protected
 *
 * @return array
 */
add_filter('password_protected', function () {
    return [
        'active'             => false,
        'password'           => false,
        'secret'             => $this->secret,
        'allowFeeds'         => false,
        'allowAdmins'        => false,
        'allowUsers'         => false,
        'allowIpAddresses'   => false,
        'allowedIpAddresses' => [],
        'title'              => $this->name()
    ];
});
```

#### Example

[](#example)

Below is a personal example of how I handle the configuration alongside ACF and [ACF Fluent](https://github.com/samrap/acf-fluent).

```
/**
 * Configuration for Sage Password Protected.
 *
 * @return array
 */
add_filter('password_protected', function () {
    return [
        'active'             => Acf::option('password_protected')->get(),
        'password'           => Acf::option('password')->get(),
        'allowFeeds'         => Acf::option('password_show_feeds')->get(),
        'allowAdmins'        => Acf::option('password_allow_administrators')->get(),
        'allowUsers'         => Acf::option('password_allow_users')->get(),
        'allowIpAddresses'   => Acf::option('password_allow_by_ip_address')->get(),
        'allowedIpAddresses' => Acf::option('password_allowed_ip_addresses')->get(),
    ];
});
```

### ACF Builder

[](#acf-builder)

If you happen to be utilizing ACF Builder, you can use my above filters along with:

```
