Skip to content

Instantly share code, notes, and snippets.

View dwanjuki's full-sized avatar

David Wanjuki dwanjuki

  • Nairobi, Kenya
  • 05:50 (UTC +03:00)
View GitHub Profile
@dwanjuki
dwanjuki / my_pmpro_cancel_membership_on_denial.php
Created September 15, 2026 11:28
Cancel membership level and subscription at payment gateway when a member is denied.
<?php
/**
* Cancel membership level and subscription at payment gateway when a member is denied.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_cancel_membership_on_denial( $user_id, $level_id ) {
@dwanjuki
dwanjuki / my_pmpro_set_visit_cookie_logged_in_users_only.php
Created September 14, 2026 11:46
Only set the pmpro_visit cookie for logged-in users
@dwanjuki
dwanjuki / my_pmproiucsv_modify_required_import_headers.php
Created September 11, 2026 13:30
Remove membership_id requirement on member import
<?php
/**
* Remove membership_id requirement on member import.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
@dwanjuki
dwanjuki / pmpro-protect-update-package.php
Created September 9, 2026 14:25
Restores the Paid Memberships Pro update package URL offered in the update transient if another plugin (e.g. thim-core) swaps it at download time. Stopgap until PMPro Update Manager ships a built-in guard; remove after that release.
<?php
/**
* Plugin Name: PMPro Hosting - Protect PMPro Update Package
* Description: Restores the Paid Memberships Pro update package URL offered in the update transient if another plugin (e.g. thim-core) swaps it at download time. Stopgap until PMPro Update Manager ships a built-in guard; remove after that release.
* Author: Paid Memberships Pro
*/
add_filter( 'upgrader_package_options', function ( $options ) {
$plugin = isset( $options['hook_extra']['plugin'] ) ? $options['hook_extra']['plugin'] : '';
if ( 'paid-memberships-pro/paid-memberships-pro.php' !== $plugin ) {
@dwanjuki
dwanjuki / my_pmpro_delete_sandbox_data.php
Created September 1, 2026 10:44
Delete all sandbox orders and sandbox subscriptions.
<?php
/**
* Delete all sandbox orders and sandbox subscriptions.
* WARNING: This permanently deletes data. Back up your database first!
*
* Does not cancel anything at the gateway.
* If necessary, delete Sandbox subscriptions via gateway dashboard.
*
* Run it ONCE: visit /wp-admin/?pmpro_delete_sandbox_data=1 as an admin,
* then remove this snippet.
@dwanjuki
dwanjuki / my_pmpro_inline_restricted_pdfs.php
Created August 28, 2026 10:18
Display restricted PDFs inline in the browser
<?php
/**
* Display restricted PDFs inline in the browser for members with access.
*
* Restrict files: https://www.paidmembershipspro.com/locking-down-protecting-files-with-pmpro/
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
@dwanjuki
dwanjuki / pmpro_ajax_timeout.php
Last active August 20, 2026 10:50 — forked from strangerstudios/pmpro_ajax_timeout.php
Tell PMPro to wait 15 seconds instead of 5 on AJAX calls
<?php
/**
* Change the PMPro AJAX timeout limit.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
<?php
/**
* Deferred-payment promo: when a member of the eligible level checks out for
* the level using the promo discount code, push their first recurring payment
* out to 1 year after their existing subscription's next payment date.
* They still pay the initial payment now.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
@dwanjuki
dwanjuki / susbsite-delete-user-remove-memberships.php
Created August 14, 2026 09:51
Remove memberships on main site when user is deleted from a subsite
<?php
/**
* Remove memberships on main site when user is deleted from a subsite.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/