WP Manifestindependent plugin directory
manifest / users / wordpress---custom-access-plugin

Premium Access Manager

Manages premium access for specific pages and users. Allows administrators to restrict content to premium members only.

by Nabin Rawat · github.com/mehetarnabin/wordpress---custom-access-plugin · website

0stars
0forks

Install

No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:

wp plugin install https://github.com/mehetarnabin/wordpress---custom-access-plugin/archive/refs/heads/main.zip

Premium Access Manager Plugin

This plugin restricts specific WordPress pages so that they can only be viewed by users who have been granted "Premium" status by an Administrator. It also includes an authenticated REST API endpoint to retrieve a list of restricted pages.

Features

  • Page Restriction: Adds a meta box to the Page editor allowing you to restrict a page to Premium members only.
  • Premium User Management: Adds a new admin screen under the Users menu to easily grant or revoke Premium status for any user.
  • Smart Redirects: Unauthorized users attempting to view a restricted page are automatically redirected to a /premium-required page (which is automatically generated upon plugin activation).
  • REST API Endpoint: Exposes a secure REST API endpoint (GET /wp-json/myplugin/v1/premium-pages) that lists all restricted pages, accessible only via WordPress Application Passwords by an Administrator.

Local Setup & Installation

Follow these steps to install and test the plugin on your local WordPress environment.

1. Installation

  1. Download the customaccessplugin.zip file.
  2. Log in to your WordPress Admin dashboard.
  3. Navigate to Plugins > Add New Plugin in the left sidebar.
  4. Click the Upload Plugin button at the top of the screen.
  5. Choose the customaccessplugin.zip file and click Install Now.
  6. Once installed, click Activate Plugin.

(Alternatively, you can extract the .zip file and place the customaccessplugin folder directly into your wp-content/plugins/ directory, then activate it from the Plugins screen).

2. Initial Setup

Upon activation, the plugin automatically creates a new page titled "Premium Required". This is the default page unauthorized users will be redirected to if they try to access restricted content.

You can edit the content of this page at any time by going to Pages > All Pages and editing the "Premium Required" page.

3. Usage Guide

Restricting a Page:

  1. Go to Pages > Add New or edit an existing page.
  2. On the right-hand sidebar, look for the "Premium Access Restriction" meta box.
  3. Check the box that says "Restrict this page to Premium Members".
  4. Publish or Update the page.
  5. If you visit this page while logged out, or while logged in as a regular (non-premium) user, you will be redirected to the "Premium Required" page.

Granting Premium Access to Users:

  1. Navigate to Users > Premium Users in the admin sidebar.
  2. You will see a list of all users on your site.
  3. Check the box on the far left next to any user you want to grant access to.
  4. Click the Save Premium Access button at the bottom of the table.
  5. The selected user(s) will now have a green checkmark indicating "Premium" status and can view restricted pages.

Using the REST API Endpoint:

  1. Go to Users > Profile.
  2. Scroll down to the "Application Passwords" section.
  3. Create a new Application Password (e.g., "API Test") and copy the generated password.
  4. Make a GET request to your site's endpoint: http://{your-local-site-url}/wp-json/myplugin/v1/premium-pages
  5. You must use Basic Authentication for this request:
    • Username: Your WordPress Admin username.
    • Password: The Application Password you just generated.
  6. The API will return a JSON array containing the IDs and Titles of all pages currently restricted to Premium members.