lwplugins/lw-memberships

Lightweight membership system with WooCommerce integration

Installs: 2

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

Type:wordpress-plugin

pkg:composer/lwplugins/lw-memberships

v1.1.4 2026-02-08 10:10 UTC

This package is auto-updated.

Last update: 2026-02-08 10:10:49 UTC


README

Warning !! This plugin is currently in alpha stage and under active development. It is not recommended for production use. APIs and database schemas may change without notice. Use at your own risk. !!

Lightweight membership system for WordPress with WooCommerce integration. Part of the LW Plugins family.

Features

  • Membership Plans - Create unlimited membership plans with customizable durations (lifetime, days, months, years)
  • Tabbed Plan Editor - Manage plans with General, Content, WooCommerce, and Members tabs
  • WooCommerce Integration - Link products to membership plans for automatic access on purchase
  • WooCommerce Subscriptions - Full support for recurring memberships with status synchronization
  • Content Restriction - Restrict posts, pages, and custom post types to specific membership plans
  • Content Hiding - Restricted content is hidden from archives, search, and feeds
  • Manual Member Management - Add and remove members directly from the plan editor
  • Shortcodes - Display restricted content and member dashboards
  • Template Overrides - Customize restriction messages via theme templates
  • Lightweight - Minimal footprint, no bloat, no upsells

Requirements

  • WordPress 6.0+
  • PHP 8.2+
  • WooCommerce (optional, for product integration)
  • WooCommerce Subscriptions (optional, for recurring memberships)

Installation

Via Composer

composer require lwplugins/lw-memberships

Manual Installation

  1. Download or clone this repository
  2. Run composer install in the plugin directory
  3. Upload to /wp-content/plugins/lw-memberships
  4. Activate the plugin through the WordPress admin

Usage

Creating Membership Plans

  1. Go to LW Plugins > Plans
  2. Click Add New
  3. Configure plan name, duration, and settings in the tabbed editor
  4. Use the Content tab to assign posts/pages
  5. Use the WooCommerce tab to link products
  6. Use the Members tab to manage members manually
  7. Save the plan

Restricting Content

  1. Edit any post, page, or custom post type
  2. Find the Membership Restriction meta box in the sidebar
  3. Select which membership plans can access this content
  4. Update/publish the post

Shortcodes

Restrict inline content:

[lw_mship_restricted plan="1,2" message="Members only content"]
  Your protected content here
[/lw_mship_restricted]

Display user's memberships:

[lw_mship_memberships show_expired="no"]

Public API Functions

// Check if user has specific plan
lw_mship_user_has_plan( int $plan_id, ?int $user_id = null ): bool

// Check if user can access content
lw_mship_user_can_access( int $post_id, ?int $user_id = null ): bool

// Get user's active memberships
lw_mship_get_user_memberships( ?int $user_id = null ): array

// Grant membership to user
lw_mship_grant_membership( int $user_id, int $plan_id, string $source = 'manual', ?int $order_id = null )

// Revoke membership from user
lw_mship_revoke_membership( int $user_id, int $plan_id ): bool

// Get all membership plans
lw_mship_get_plans( bool $active_only = true ): array

Template Overrides

Copy templates from templates/ to your theme's lw-memberships/ directory to customize:

  • restriction-not-logged-in.php - Message for logged out users
  • restriction-no-access.php - Message for users without required membership
  • restriction-expired.php - Message for expired memberships
  • restriction-paused.php - Message for paused memberships
  • my-memberships.php - User's membership list

Hooks

Actions

// Fired when membership is granted
do_action( 'lw_mship_membership_granted', $membership_id, $user_id, $plan_id );

// Fired when membership is revoked
do_action( 'lw_mship_membership_revoked', $membership_id, $user_id, $plan_id );

// Fired when membership expires
do_action( 'lw_mship_membership_expired', $membership_id, $user_id, $plan_id );

Filters

// Customize supported post types for restriction
apply_filters( 'lw_mship_supported_post_types', array $types );

Development

# Install dependencies
composer install

# Run code standards check
composer phpcs

# Auto-fix code standards
composer phpcbf

Database Tables

The plugin creates 4 custom tables:

Table Description
{prefix}_lw_mship_plans Membership plans
{prefix}_lw_mship_plan_products Plan-Product associations
{prefix}_lw_mship_user_memberships User memberships
{prefix}_lw_mship_content_rules Content restriction rules

Related Plugins

License

GPL-2.0-or-later