Skip to content

Instantly share code, notes, and snippets.

View JarrydLong's full-sized avatar

Jarryd Long JarrydLong

  • Paid Memberships Pro
  • South Africa
  • 01:27 (UTC +02:00)
  • X @jarrydlong
View GitHub Profile
<?php //do not copy
// Store the old levels before the change.
function pmpro_store_old_levels( $level_id, $user_id ) {
$old_level_we_want_to_remember = 7;
// Store the current level in a static variable.
$current_level = pmpro_getMembershipLevelForUser( $user_id );
if ( ! empty( $current_level ) && $current_level === $old_level_we_want_to_remember ) {
<?php //do not copy
add_filter('query', function ($query) {
if (strpos($query, 'CREATE TABLE') !== false || strpos($query, 'ALTER TABLE') !== false) {
error_log("DBDelta altering query: " . $query);
}
return $query;
});
<?php //do not copy
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
<?php //do not copy
/**
* This recipe unhooks a function that the Member Directory uses to redirect profile URL's to pretty permalinks
*
* 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/
*/
@JarrydLong
JarrydLong / remove-custom-trial-for-members.php
Last active April 16, 2025 06:02 — forked from andrewlimaza/remove-custom-trial-for-members.php
Remove custom trial for levels for existing and past members Paid Memberships Pro (Trial only used once)
<?php
/**
* Removes custom trial for active and past members.
* Adjust this code accordingly to price your membership level when removing the trial.
* To add this code to your site, please follow this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_remove_custom_trial( $level ) {
if ( is_admin() || ! is_user_logged_in() ) {
return $level;
<?php //do not copy
/**
* This recipe gets a customer's Tax ID and country from the webhook
*
* Create two User fields with the names pmpro_stripe_tax_type and pmpro_stripe_tax_id to view
* the tax type and tax ID in the member's profile.
*
* 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.
/**
* Intends to protect uploads within the uploads/sites/x/ file structure
* This code assumes that PMPro is installed and active on each multisite installation
*/
rewrite ^/wp-content/uploads/(sites/[0-9]+/)?(.+\.(pdf|doc|docx|ppt|zip|png))$ /wp-content/plugins/paid-memberships-pro/services/getfile.php?file=$1$2 last;
<?php //do not copy
/**
* This recipe filters the search request from the member directory into the membership map
*
* 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 //do not copy
function my_pmpro_registration_checks( $okay, $level ){
global $pmpro_msg, $pmpro_msgt;
/**
* Restricts based on gender field - START
*/
@JarrydLong
JarrydLong / change-add-paypal-express.php
Created March 20, 2025 06:07 — forked from kimwhite/change-add-paypal-express.php
Change text for add paypal express to checkout translation strings
<?php
// Add this code below to your PMPro Customizations plugin - http://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
add_filter( 'gettext', 'change_text_for_add_paypal_express', 20, 3 );
/**
* @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
*/
function change_text_for_add_paypal_express( $translated, $text, $domain ) {
switch ( $domain ) {
case 'pmpro-add-paypal-express':
switch ( $text ) {