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 / 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;
<?php
// 1. content_matches_restriction_exceptions
public function content_matches_restriction_exceptions() {
$cache_key = 'lp_restriction_exception_' . $this->post_id;
if ( false === ( $match = get_transient( $cache_key ) ) ) {
<?php
add_filter('leaky_paywall_basic_shipping_validation', 'zeen_ignore_state_for_international', 10, 2);
function zeen_ignore_state_for_international($errors, $fields)
{
// if the user selects GB (Great Britian), then remove the state validation
if ($fields['country'] == 'GB') {
unset($errors['state_empty']);
<?php
add_action('leaky_paywall_active_campaign_after_new_subscriber', 'zeen_add_custom_field_for_active_campaign', 10, 2 );
function zeen_add_custom_field_for_active_campaign( $user_id, $contact_id ) {
$field_id = 1; // retrieved from the admin settings custom fields table
$value = sanitize_text_field( $_POST['2_field_8_1'] ); // custom registration field name
$api = new Leaky_Paywall_Active_Campaign_Api();
<?php
add_filter('leaky_paywall_account_setup_validation', 'zeen_validate_email_blacklist', 20, 2 );
function zeen_validate_email_blacklist($errors, $fields)
{
// edit to the domains/strings you would like to block from registering
$blacklist = array(
'gmail',
<?php
add_action('leaky_paywall_before_create_stripe_subscription', 'endo_handle_product_for_recurring_checkout', 20, 2);
function endo_handle_product_for_recurring_checkout($customer, $fields) {
$stripe = leaky_paywall_initialize_stripe_api();
try {
$invoice_item = $stripe->invoiceItems->create([
<?php
// Send an email to the subscriber when Authorize.net sends a net.authorize.customer.subscription.expired webhook event
// Notice the action is the event name, with the periods changed out for underscores
// Any event can be accessed that way
add_action('leaky_paywall_net_authorize_customer_subscription_expired', 'zeen_send_expired_notice', 10, 2);
function zeen_send_expired_notice($user, $webhook_data)
{
<?php
add_filter('leaky_paywall_new_email_message', 'zeen_maybe_update_email_message', 99, 2);
function zeen_maybe_update_email_message($message, $user_id) {
$user = get_user_by( 'ID', $user_id );
$transaction_id = leaky_paywall_get_transaction_id_from_email( $user->user_email );
$transaction = get_post($transaction_id);