Skip to content

Instantly share code, notes, and snippets.

Avatar
👽
Craft

Jeremy Green greenhornet79

👽
Craft
View GitHub Profile
View leaky-paywall-add-fee.php
<?php
add_action('leaky_paywall_after_create_recurring_customer', 'zeen101_add_fee_to_recurring_checkout');
function zeen101_add_fee_to_recurring_checkout( $customer ) {
$fee_amount = 999; // in cents
$stripe = leaky_paywall_initialize_stripe_api();
View leaky-paywall-simplecirc-gift-data.php
<?php
add_filter( 'leaky_paywall_simplecirc_gift_giver_data', 'zeen_add_gift_giver_data_to_simplecirc', 10, 2 );
function zeen_add_gift_giver_data_to_simplecirc( $data, $gift_details ) {
if ( isset( $gift_details['gift_giver_address'])) {
$data['address_1'] = $gift_details['gift_giver_address'];
}
View leaky-paywall-gift-save-custom-fields.php
<?php
add_filter( 'lp_gift_subs_details_array', 'zeen_save_gift_giver_address' );
function zeen_save_gift_giver_address( $data ) {
if ( isset( $_POST['gift_giver_address'] ) ) {
$data['gift_giver_address'] = sanitize_text_field( $_POST['gift_giver_address'] );
}
View leaky-paywall-gift-custom-fields.php
<?php
add_action( 'lp_gift_sub_after_billing_fields', 'zeen_gift_giver_address_fields');
function zeen_gift_giver_address_fields() {
?>
<h3>Gift Giver Address</h3>
<p class="form-row address-field">
<label>Address <i class="required">*</i></label>
<input type="text" value="" name="gift_giver_address" placeholder="House number and street name" required="">
View leaky-paywall-simplecirc-phone.php
<?php
add_filter('leaky_paywall_simplecirc_subscriber_data', 'zeen_tester_add_phone');
function zeen_tester_add_phone( $data )
{
// this is the name of the field generated by the Leaky Paywall Custom Registration Fields add-on.
// Please change the field name to whatever is being used in your own custom field for phone number.
if ( !isset($_POST['0_field_1_1'] ) ) {
View leaky-paywall-setting-management.php
<?php
// adjust who can edit and manage the Leaky Paywall settings menu
// use WordPress capabilities https://wordpress.org/support/article/roles-and-capabilities/
add_filter( 'manage_leaky_paywall_settings', 'zeen101_adjust_lp_setting_management' );
function zeen101_adjust_lp_setting_management( $cap ) {
// allow editors
return 'delete_others_posts';
View lp-redirect-if-no-access.php
<?php
add_action('wp', 'zeen_redirect_if_no_access');
function zeen_redirect_if_no_access()
{
$restricted_page_id = 79791;
$settings = get_leaky_paywall_settings();
View leaky-paywall-add-level-id-to-body.php
<?php
add_filter('body_class', 'zeen101_add_lp_level_to_body');
function zeen101_add_lp_level_to_body($classes)
{
$level_ids = leaky_paywall_subscriber_current_level_ids();
if (!$level_ids) {
return $classes;
View leaky-paywall-corporate-display-custom-field.php
<?php
// display data on the WP user profile page
add_action('show_user_profile', 'zeen101_corporate_show_extra_profile_fields');
add_action('edit_user_profile', 'zeen101_corporate_show_extra_profile_fields');
function zeen101_corporate_show_extra_profile_fields($user)
{ ?>
View leaky-paywall-corporate-save-fields.php
<?php
// save data to the user after the corporate subscription is created
add_action('leaky_paywall_after_corporate_subscription_user_created', 'zeen101_corporate_after_created', 10, 2);
function zeen101_corporate_after_created($user_id, $post_data)
{
if (isset($post_data['phone'])) {
update_user_meta($user_id, '_phone', sanitize_text_field($post_data['phone']));
}