WP Manifestindependent plugin directory
manifest / users / wp-access-state-monitor-demo

WP Access State Monitor Demo

A WordPress plugin demonstrating a reusable access-state monitoring pattern using secure AJAX polling and forced logout when a user's entitlement changes.

by Troy Whitney · github.com/iillc/wp-access-state-monitor-demo · 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/iillc/wp-access-state-monitor-demo/archive/refs/heads/main.zip

A WordPress plugin demonstrating a reusable access-state monitoring pattern using secure AJAX polling and forced logout when a user's entitlement changes.

Overview

This plugin showcases a common membership/access-control requirement: a user is allowed into a protected area, but their access state may change during the session.

The current implementation focuses on a Memberium-style tag workflow:

  • a user qualifies for monitoring when they have a specific access tag
  • the plugin polls the server at a fixed interval
  • if a deny-state tag appears, the plugin forces logout

The architecture is intentionally scoped as a pattern demonstration rather than a full membership product.

Design Choice: Polling

This demo uses client-side polling because the monitored condition can change after page load and because many WordPress membership stacks do not provide a reliable browser-session revocation mechanism out of the box.

What This Demonstrates

This repository is intended as a focused example of:

  • WordPress plugin architecture
  • secure AJAX polling with nonce validation
  • session-aware access enforcement
  • page-scoped script loading
  • adapter-style integration with a third-party membership system
  • clean separation between access rules, transport, and frontend behavior
  • maintainable prefixed WordPress code

Demo Scenario

This demo models a real-world access-control requirement:

  • users enter a protected page after meeting an access rule
  • while they remain on that page, the system periodically re-checks their state
  • if their status changes to a denied state, the session is immediately ended

In this example, the access state is represented by Memberium tags, but the pattern can be adapted to other systems.

Features

  • page-specific monitoring
  • AJAX polling with nonce verification
  • forced logout when deny-state is detected
  • optional Memberium integration through an adapter
  • filterable config for page ID, tag IDs, interval, and logout URL
  • standalone, portfolio-friendly structure

Technical Notes

This repository was refactored from a small live-site utility into a cleaner demonstration plugin.

It intentionally:

  • removes site-specific debug output and environment assumptions
  • isolates the third-party tag lookup in an adapter class
  • keeps configuration lightweight and code-review friendly
  • demonstrates the pattern without overbuilding a full admin settings UI

File Structure

wp-access-state-monitor-demo.php
includes/
  class-iillc-asm-plugin.php
  class-iillc-asm-access-monitor.php
  class-iillc-asm-ajax.php
  class-iillc-asm-memberium-adapter.php
assets/
  js/iillc-access-monitor.js
README.md
uninstall.php
LICENSE

Installation

  1. Install WordPress.
  2. Memberium is optional. If it is not installed, the plugin still demonstrates the monitoring architecture and AJAX flow, but tag checks will return false unless behavior is customized through filters.
  3. Copy the plugin into wp-content/plugins/.
  4. Activate the plugin.
  5. Adjust the demo configuration with the iillc_asm_config filter if needed.

Example Configuration

add_filter(
    'iillc_asm_config',
    function( $config ) {
        $config['page id'] = 4;
        $config['qualifying access state'] = '331';
        $config['deny state']     = '116';
        $config['poll interval']  = 300;
        $config['logout url']     = wp_logout_url( home_url( '/' ) );

        return $config;
    }
);

Naming Convention

This project uses the iillc_ / IILLC_ prefix for functions, classes, and constants.

This reflects my production practice of:

  • preventing naming collisions
  • identifying authored code quickly
  • maintaining consistency across large WordPress systems

Scope

This is a portfolio demonstration, not a complete membership framework.

It intentionally excludes:

  • full admin settings pages
  • multi-rule orchestration
  • event logging and audit history
  • alternate authentication providers
  • advanced UI messaging
  • background sync workflows

Why This Repo Exists

Most of my production work has involved implementing business-specific access rules inside live WordPress systems rather than packaging them as public plugins.

This repository extracts one of those patterns into a sanitized, standalone example that is easier for hiring teams and technical reviewers to evaluate.

What Reviewers Should Notice

  • page-scoped script loading (no global overhead)
  • adapter pattern isolating Memberium-specific logic
  • clean separation between monitoring logic and transport (AJAX)
  • nonce-protected AJAX endpoint
  • minimal, intentional frontend polling loop
  • forced logout kept simple and decoupled from UI concerns
  • configuration exposed via filters instead of admin UI (demo scope decision)

Review Notes

  • The default demo configuration uses placeholder page/tag IDs to reflect the original production pattern.
  • If Memberium is not installed, the plugin still demonstrates the architecture and AJAX flow, but no tag checks will succeed unless filters are used.

License

MIT