Skip to content

Instantly share code, notes, and snippets.

View greenhornet79's full-sized avatar
👽
Craft

Jeremy Green greenhornet79

👽
Craft
View GitHub Profile
@greenhornet79
greenhornet79 / lp-hide-paypal.php
Last active August 17, 2026 15:55
hide paywall
<?php
add_filter( 'leaky_paywall_enabled_gateways', function ( $gateways ) {
unset( $gateways['paypal'] ); // hides PayPal on the form
return $gateways;
} );
@greenhornet79
greenhornet79 / lp-custom-event-insights.php
Created July 21, 2026 20:11
custom event to Leaky Paywall Insights
<?php
add_action( 'leaky_paywall_rest_after_create_subscriber', 'my_custom_signup_event', 10, 3 );
function my_custom_signup_event( $user_id, $request, $level ) {
if ( ! function_exists( 'leaky_paywall_track_event' ) ) {
return;
}
@greenhornet79
greenhornet79 / lp-hide-tax.php
Created July 17, 2026 20:41
hidden taxonomies
<?php
add_filter('leaky_paywall_settings_hidden_taxonomies', function($hidden) {
// Hide taxonomies with too many terms to render in the dropdown.
$hidden[] = 'post_tag'; // if they have 10K+ tags
$hidden[] = 'their_custom_tax';
return $hidden;
});
<?php
add_action( 'leaky_paywall_stripe_invoice_payment_succeeded', 'mysite_send_stripe_renewal_thank_you', 10, 2 );
function mysite_send_stripe_renewal_thank_you( $user, $invoice ) {
if ( empty( $invoice->billing_reason ) || 'subscription_cycle' !== $invoice->billing_reason ) {
return;
}
<?php
// this requires an edu email address to sign up for the level. Can be changed to whatever the requirements are.
// front end check
add_filter('leaky_paywall_account_setup_validation', function ($errors, $fields) {
$edu_level_id = '6';
if (isset($fields['level_id']) && $edu_level_id === $fields['level_id']) {
@greenhornet79
greenhornet79 / lp_adjust_user_role.php
Created March 3, 2026 16:36
Leaky Paywall user role adjust
<?php
add_filter( 'leaky_paywall_userdata_before_user_create', function( $user_data ) {
// Check if a level_id is available in the registration data.
// Adjust the level ID and role to match your setup.
if ( isset( $_POST['level_id'] ) && '0' === $_POST['level_id'] ) {
$user_data['role'] = 'free_subscriber';
}
return $user_data;
} );
<?php
// add fields to the gift form
add_action('lp_gift_sub_after_recipient_fields', 'endo_add_custom_fields_on_gift_form' );
function endo_add_custom_fields_on_gift_form() {
?>
<p>
<label>Your coworking space</label>
@greenhornet79
greenhornet79 / terms-conditions.php
Last active August 18, 2025 16:19
Add a terms and conditions checkbox to the Leaky Paywall registration form.
<?php
// add fields to registration form
add_action('leaky_paywall_after_password_registration_field', 'endo_custom_tos_registration_fields', 100, 2);
function endo_custom_tos_registration_fields($level_id, $level)
{
// do not show on free levels
if ( $level['price'] == 0 ) {
return;
<?php
add_shortcode('endo_user_purchased_downloads', function () {
if (! is_user_logged_in()) {
return '<p>Please log in to see your downloads.</p>';
}
$user_id = get_current_user_id();
<?php
add_shortcode('leaky_paywall_read_banner', 'leaky_paywall_read_banner');
function leaky_paywall_read_banner()
{
$restriction = new Leaky_Paywall_Restrictions();
$articles_read = $restriction->get_content_viewed_by_user();
$articles_read_count = 0;