Skip to content

Instantly share code, notes, and snippets.

View andrewlimaza's full-sized avatar

Andrew Lima andrewlimaza

View GitHub Profile
@andrewlimaza
andrewlimaza / pmpro-update-webhook-id-paypal.php
Created April 17, 2026 13:48
PMPro update PayPal Webhook ID value for the new PayPal gateway.
<?php
/**
* Adjust the PMPro PayPal gateway webhook ID to point to a new webhook that was manually created.
* Run this in your browser once yoursite.com/wp-admin/?pp_webhook_id=12345
* Delete this snippet when no longer needed.
*
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
add_action( 'admin_init', function() {
if ( ! isset( $_GET['pp_webhook_id'] ) ) {
@andrewlimaza
andrewlimaza / override-set-expiration-date-pmpro.php
Last active April 15, 2026 11:25
Override Set Expiration Date logic to push out the expiration date based on time of checkout
<?php
/**
* Manually overrides the YYYY-MM-DD settings of a set expiration date level.
* If the checkout is 15-30 July of the current year, push it out by another year.
* The example expiration date is 31 July of current year in the Set Expiration Date Add On.
*
* Tweak all the code accordingly for your needs, and add level ID checks for multiple level compatibility.
* To add this code to your site you may follow this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_override_sed_date( $date ) {
@andrewlimaza
andrewlimaza / allow-gateway-swop-query-param.php
Last active April 21, 2026 15:57
Allow query parameter &gateway=xxxx for multiple gateway options at checkout PMPro.
<?php
/**
* Allows you to hotswap gateway logic at checkout via query parameter.
* Helpful if the gateway doesn't have native gateway swapping capabilities.
* Add &gateway=paypal (for example) to your checkout URL to load the new PayPal payment gateway.
*
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
add_filter( 'pmpro_valid_gateways', function( $gateways ) {
$gateways[] = 'paypal'; //Change paypal to any other gateway you have installed/configured.
@andrewlimaza
andrewlimaza / wll-generate-records.php
Created March 31, 2026 20:02 — forked from k2sobot/wll-generate-records.php
WP-CLI command to generate test login records for When Last Login plugin (wll_records CPT)
<?php
/**
* WP-CLI command to generate test login records for When Last Login.
*
* INSTALLATION:
* Add this line to your child theme's functions.php or any plugin file:
* require_once __DIR__ . '/wll-generate-records.php';
*
* USAGE:
* wp wll-generate-records 1000
@andrewlimaza
andrewlimaza / pmpro-always-remove-donation-only-level.php
Created March 26, 2026 13:43
Remove donation only level if it's the first level purchased or it's on it's own group.
<?php
/**
* Remove the donation only level if it's the first level purchased (including if it's your only level on your site).
* Remove the "Donation Only Level" setting from the level if you want members to keep this level.
*
* To implement this code onto your site follow this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmprodon_pmpro_checkout_before_change_membership_level( $user_id, $morder ) {
global $pmprodon_existing_member_flag, $pmpro_level;
@andrewlimaza
andrewlimaza / pmpro-pbc-sed-keep-expiration-date.php
Created March 17, 2026 13:44
Keep expiration date for Set Expiration Date AND Pay By Check Add On for PMPro
<?php
/**
* This resolves an issue where the Set Expiration Date would change based on date of manual order confirmation.
* To add this code to your site, follow this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmprosed_force_set_expiration_enddate( $enddate, $user_id, $level, $startdate ) {
// Bail if no enddate or a NULL enddate.
if ( $enddate === "NULL" || empty( $enddate ) ) {
return $enddate;
@andrewlimaza
andrewlimaza / pmpro-courses-add-comments.php
Created January 12, 2026 09:32
Enable comments on PMPro Courses and Lessons.
<?php
/**
* Enable comments for Courses and Lessons for members with access.
* People who don't have access will only be able to view comments only. Great for upselling lessons and courses.
*
* To add this code to your site, follow this guide - https://www.paidmembershipspro.com/documentation/templates/customizing-via-a-custom-plugin/
*/
function my_pmpro_courses_enable_comments( $open, $post_id ) {
// Check if the person has access to the post type to comment.
@andrewlimaza
andrewlimaza / remove-period-from-pricing.php
Created December 23, 2025 07:47
Remove trailing full stop from level pricing.
<?php
/**
* Removes the last "." from the level's cost text.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_remove_period_from_cost_text( $cost_text, $level, $tags, $short ) {
return rtrim( $cost_text, '. ' );
}
add_filter( 'pmpro_level_cost_text', 'my_pmpro_remove_period_from_cost_text', 10, 4 );
@andrewlimaza
andrewlimaza / allow-iframe-wp-kses-post.php
Created December 19, 2025 14:21
Allow <iframe> in content around wp_kses_post functions
<?php
/**
* Allow <iframe> code in wp_kses_post calls.
* Useful for embedding videos in Memberlite theme banner descriptions.
*
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_allow_iframe_wp_kses_post( $tags, $context ) {
if ( 'post' === $context ) {
@andrewlimaza
andrewlimaza / change-pmprorate-downgrade-text.php
Created December 17, 2025 12:38
Replace !!pmprorate_downgrade_text!! wording using gettext
<?php
/**
* Change the wording of the Prorations Downgrade Text.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/documentation/templates/customizing-via-a-custom-plugin/
*/
function my_pmpro_change_text( $translated_text, $text, $domain ) {
if ( $domain == 'pmpro-proration' ) {
if ( $text == 'Downgrading to %s on %s.' ) {
$translated_text = 'Changing to %s on %s.'; // Adjust the wording here.
}