Skip to content

Instantly share code, notes, and snippets.

View dwanjuki's full-sized avatar

David Wanjuki dwanjuki

  • Nairobi, Kenya
  • 08:01 (UTC +03:00)
View GitHub Profile
@dwanjuki
dwanjuki / my_pmpro_clear_existing_card_details_run.php
Created November 24, 2026 09:26
One-time tool to clear card details (type, last 4 digits, expiration) from existing PMPro orders.
<?php
/**
* One-time tool to clear card details (type, last 4 digits, expiration) from existing PMPro orders.
*
* Usage:
* 1. Back up your database.
* 2. As an administrator, visit any admin page with ?pmpro_clear_card_details=1 added to the URL,
* for example: /wp-admin/?pmpro_clear_card_details=1
* 3. Click the confirmation link in the notice that appears. The link carries a nonce, so a
* URL alone (or a link on another site) can't trigger the clear.
@dwanjuki
dwanjuki / my_pmpro_clear_order_card_details.php
Created November 24, 2026 08:58
Clear card details (type, last 4 digits, expiration) from PMPro orders on insert and update
<?php
/**
* Clear card details (type, last 4 digits, expiration) from PMPro orders.
*
* Runs after every order insert and update. It writes to the database directly
* with $wpdb so it doesn't call saveOrder() again and loop.
*
* 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.
<?php
/**
* Translate strings in the Streamvid PMPro invoice template (jws-streamvid
* get_invoice_html_pmpro AJAX handler) and nowhere else.
*
* Uncomment a line in $map and change the right-hand side to translate it.
*
* 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 / pmproeewe-per-level-schedules.php
Last active November 6, 2026 09:10
Per-level schedules for the Extra Expiration Warning Emails Add On
<?php
/**
* Per-level schedules for the PMPro Extra Expiration Warning Emails Add On.
*
* Edit my_pmproeewe_level_schedules() to set, for each level ID, how many days before
* expiration to send a warning and which email template to use. Levels can share a
* day value with different templates.
*
* How it works: the Add On runs one combined schedule (every day value used by any level).
* For each member it finds, this snippet checks whether the member's level has an email
@dwanjuki
dwanjuki / my_login_redirect_to_buddyboss_profile.php
Created November 2, 2026 15:11
Redirect members to their BuddyBoss profile page on login.
<?php
/**
* Redirect members to their BuddyBoss profile page on login.
*
* Uses BuddyBoss's dynamic /members/me/ link, which resolves to the
* logged-in user's profile. Requires the BuddyBoss Platform (or BuddyPress)
* profiles component to be active.
* See: https://buddyboss.com/docs/dynamic-user-profile-links/
*
* You can add this recipe to your site by creating a custom plugin
<?php
/**
* Display the "short" level cost text when using the {{ membership_cost }} email variable.
*
* 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_email_data_membership_cost_short( $data, $email ) {
@dwanjuki
dwanjuki / my_pmpro_hide_no_access_message_homepage.php
Last active October 30, 2026 09:49
Hide the PMPro "Membership Required" content message card on the blog homepage.
<?php
/**
* Hide the PMPro protected content message card on the blog homepage.
*
* 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_hide_no_access_message_homepage( $html, $level_ids ) {
@dwanjuki
dwanjuki / my_pmpro_redirect_logged_out_from_restricted_content.php
Created October 23, 2026 12:28
Redirect logged-out visitors away from restricted content to the login page.
<?php
/**
* Redirect logged-out visitors away from restricted content to the login page.
*
* When a logged-out visitor hits a post/page that requires membership,
* they are redirected to the login page with a redirect_to parameter
* pointing back to the content.
*
* 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.
@dwanjuki
dwanjuki / my_pmpro_block_cancel_for_expiring_levels.php
Last active October 9, 2026 14:48
Prevent members from cancelling a membership that has an expiration date
<?php
/**
* Prevent members from cancelling a membership that has an expiration date.
*
* - Removes the "Cancel" link from the Membership Account page and Billing page
* for any level with an expiration date set for that member.
* - Blocks cancellation processing via the pmpro_cancel_should_process filter.
*
* 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.
@dwanjuki
dwanjuki / my_pmprolpv_always_restrict_posts_from_category.php
Created October 8, 2026 11:25
Prevent the Limit Post Views Add On from granting free access to posts in specific categories
<?php
/**
* Prevent the Limit Post Views Add On from granting free access to posts in specific categories.
*
* 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/
*/