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
Requires
- php: >=8.2
- composer/installers: ^2.0
Requires (Dev)
- phpcompatibility/phpcompatibility-wp: ^2.1
- phpunit/phpunit: ^10.0
- squizlabs/php_codesniffer: ^3.0
- wp-coding-standards/wpcs: ^3.0
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
- Download or clone this repository
- Run
composer installin the plugin directory - Upload to
/wp-content/plugins/lw-memberships - Activate the plugin through the WordPress admin
Usage
Creating Membership Plans
- Go to LW Plugins > Plans
- Click Add New
- Configure plan name, duration, and settings in the tabbed editor
- Use the Content tab to assign posts/pages
- Use the WooCommerce tab to link products
- Use the Members tab to manage members manually
- Save the plan
Restricting Content
- Edit any post, page, or custom post type
- Find the Membership Restriction meta box in the sidebar
- Select which membership plans can access this content
- 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 usersrestriction-no-access.php- Message for users without required membershiprestriction-expired.php- Message for expired membershipsrestriction-paused.php- Message for paused membershipsmy-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
- LW SEO - Lightweight SEO plugin
- LW Disable - Disable WordPress features
- LW Site Manager - Site maintenance via AI/REST
License
GPL-2.0-or-later