Skip to Content
DeveloperHooks & Filters

Hooks & Filters

LW Plugins provide WordPress hooks and filters for third-party integration and customization.


LW SEO

Filters

lw_seo_markdown_output

Filter the final markdown output for a post, page, or term.

ParameterTypeDescription
$outputstringThe generated markdown string
$objectWP_Post|WP_TermThe source object
add_filter( 'lw_seo_markdown_output', function ( string $output, $object ): string { // Append custom footer to markdown output return $output . "\n\n---\nPowered by My Site"; }, 10, 2 );

lw_seo_markdown_is_supported

Filter whether the markdown endpoint is supported for the current request.

ParameterTypeDescription
$supportedboolWhether markdown is supported (default: true)
$wp_queryWP_QueryThe current query object
add_filter( 'lw_seo_markdown_is_supported', function ( bool $supported, WP_Query $query ): bool { // Disable markdown for a specific post type if ( $query->is_singular( 'secret_post_type' ) ) { return false; } return $supported; }, 10, 2 );

lw_seo_markdown_frontmatter

Filter the frontmatter data array before it is rendered in markdown output.

ParameterTypeDescription
$dataarrayFrontmatter key-value pairs
$objectWP_Post|WP_TermThe source object
add_filter( 'lw_seo_markdown_frontmatter', function ( array $data, WP_Post $post ): array { $data['custom_field'] = get_post_meta( $post->ID, 'my_field', true ); return $data; }, 10, 2 );

lw_seo_markdown_body

Filter the markdown body content (after HTML-to-markdown conversion).

ParameterTypeDescription
$bodystringThe markdown body content
$objectWP_Post|WP_TermThe source object
add_filter( 'lw_seo_markdown_body', function ( string $body, WP_Post $post ): string { // Add a disclaimer to all markdown bodies return $body . "\n\n> This content is copyrighted."; }, 10, 2 );

lw_seo_content_signals

Filter the resolved content signals (ai-train, ai-input, search) for a post or global context.

ParameterTypeDescription
$signalsarrayContent signal values
$objectWP_Post|nullThe post object (null for global)
add_filter( 'lw_seo_content_signals', function ( array $signals, ?WP_Post $post ): array { // Override AI training signal for specific category if ( $post && has_category( 'private', $post ) ) { $signals['ai-train'] = 'disallow'; } return $signals; }, 10, 2 );

lw_seo_meta_box_post_types

Filter which post types show the SEO meta box.

ParameterTypeDescription
$post_typesarrayArray of post type slugs
add_filter( 'lw_seo_meta_box_post_types', function ( array $types ): array { // Remove meta box from a custom post type return array_diff( $types, [ 'my_custom_type' ] ); } );

Filters

Get the current user’s consent categories and their states.

ParameterTypeDescription
$defaultarrayDefault value (pass empty array)

Returns: array<string, bool> - Category names mapped to consent state.

$categories = apply_filters( 'lw_cookie_consent_categories', [] ); if ( ! empty( $categories['marketing'] ) ) { // User consented to marketing - load tracking scripts }

Check if the user has given any cookie consent.

ParameterTypeDescription
$defaultboolDefault value (pass false)
$has_consent = apply_filters( 'lw_cookie_has_consent', false ); if ( $has_consent ) { // User has interacted with the cookie banner }

Check if a specific cookie category is allowed.

ParameterTypeDescription
$defaultboolDefault value (pass false)
$categorystringCategory to check: necessary, functional, analytics, marketing
$analytics_allowed = apply_filters( 'lw_cookie_is_category_allowed', false, 'analytics' ); if ( $analytics_allowed ) { // Load analytics scripts }

Get the current consent ID (unique identifier for the consent record).

ParameterTypeDescription
$defaultstring|nullDefault value (pass null)
$consent_id = apply_filters( 'lw_cookie_consent_id', null );

Override whether a specific script should be blocked before consent.

ParameterTypeDescription
$should_blockboolWhether the script should be blocked
$handlestringScript handle
$srcstringScript source URL
$categorystringDetected category
add_filter( 'lw_cookie_should_block_script', function ( $should_block, $handle, $src, $category ) { // Don't block my plugin's pixel - I handle consent myself if ( $handle === 'my-plugin-pixel' ) { return false; } return $should_block; }, 10, 4 );

LW LMS

Filters

lw_lms_has_course_access

Filter whether a user has access to a course.

ParameterTypeDescription
$has_accessboolWhether the user has access
$course_idintCourse ID
$user_idintUser ID
add_filter( 'lw_lms_has_course_access', function ( bool $has_access, int $course_id, int $user_id ): bool { // Grant access to all courses for admins if ( user_can( $user_id, 'manage_options' ) ) { return true; } return $has_access; }, 10, 3 );

lw_lms_has_lesson_access

Filter whether a user has access to a specific lesson.

ParameterTypeDescription
$has_accessboolWhether the user has access
$lesson_idintLesson ID
$user_idintUser ID
add_filter( 'lw_lms_has_lesson_access', function ( bool $has_access, int $lesson_id, int $user_id ): bool { // Custom access logic return $has_access; }, 10, 3 );

Actions

lw_lms_lesson_completed

Fires when a user marks a lesson as completed.

ParameterTypeDescription
$lesson_idintLesson ID
$user_idintUser ID
add_action( 'lw_lms_lesson_completed', function ( int $lesson_id, int $user_id ): void { // Send notification or award points }, 10, 2 );

lw_lms_course_completed

Fires when a user completes all lessons in a course.

ParameterTypeDescription
$course_idintCourse ID
$user_idintUser ID
add_action( 'lw_lms_course_completed', function ( int $course_id, int $user_id ): void { // Issue certificate or grant achievement }, 10, 2 );

lw_lms_attachment_downloaded

Fires when a user downloads a protected course/lesson attachment.

ParameterTypeDescription
$attachment_idintAttachment ID
$user_idintUser ID
add_action( 'lw_lms_attachment_downloaded', function ( int $attachment_id, int $user_id ): void { // Log download activity }, 10, 2 );

LW Memberships

Filters

lw_mship_supported_post_types

Filter which post types support content restriction.

ParameterTypeDescription
$typesarrayArray of post type slugs
add_filter( 'lw_mship_supported_post_types', function ( array $types ): array { $types[] = 'my_custom_type'; return $types; } );

lw_mship_my_account_template

Filter the WooCommerce My Account memberships tab template.

ParameterTypeDescription
$templatestringTemplate HTML content

lw_mship_member_discount

Filter the calculated member discount amount.

ParameterTypeDescription
$discountfloatDiscount amount
$productWC_ProductWooCommerce product
$user_idintUser ID

Actions

lw_mship_membership_granted

Fires when a membership is granted to a user.

ParameterTypeDescription
$membership_idintMembership record ID
$user_idintUser ID
$plan_idintPlan ID
add_action( 'lw_mship_membership_granted', function ( int $membership_id, int $user_id, int $plan_id ): void { // Send welcome email or trigger onboarding }, 10, 3 );

lw_mship_membership_revoked

Fires when a membership is cancelled/revoked.

ParameterTypeDescription
$membership_idintMembership record ID
$user_idintUser ID
$plan_idintPlan ID
add_action( 'lw_mship_membership_revoked', function ( int $membership_id, int $user_id, int $plan_id ): void { // Clean up user access or send notification }, 10, 3 );

lw_mship_membership_expired

Fires when a membership expires (via cron check).

ParameterTypeDescription
$membership_idintMembership record ID
$user_idintUser ID
$plan_idintPlan ID
add_action( 'lw_mship_membership_expired', function ( int $membership_id, int $user_id, int $plan_id ): void { // Send renewal reminder or downgrade access }, 10, 3 );

lw_mship_check_ending_soon

Fires during cron to check for memberships ending soon (used internally for email notifications).


Shared Hook

lw_plugins_overview_cards

Action hook fired on the LW Plugins overview admin page. Used internally by each plugin to render its card. Third-party plugins can use this to add custom cards to the LW Plugins dashboard.

add_action( 'lw_plugins_overview_cards', function (): void { echo '<div class="lw-plugin-card">My Custom Card</div>'; } );