Skip to content

Instantly share code, notes, and snippets.

View JarrydLong's full-sized avatar

Jarryd Long JarrydLong

  • Paid Memberships Pro
  • South Africa
  • 20:55 (UTC +02:00)
  • X @jarrydlong
View GitHub Profile
<?php //do not copy
//Remove the current text we add to PMPro no access message
function mypmpro_remove_original_ec_text(){
remove_filter( 'pmpro_no_access_message_body', 'pmproec_pmpro_text_filter' ); // PMPro 3.1+
remove_filter( 'pmpro_non_member_text_filter', 'pmproec_pmpro_text_filter' ); // Pre-PMPro 3.1
remove_filter( 'pmpro_not_logged_in_text_filter', 'pmproec_pmpro_text_filter' ); // Pre-PMPro 3.1
}
add_action( 'init' ,'mypmpro_remove_original_ec_text' );
<?php //do not copy
function my_pmpro_email_headers_email_confirmation( $headers, $email ) {
if( ! function_exists( 'pmproec_isEmailConfirmationLevel' ) ) {
return $headers;
}
// BCC email confirmation emails to another email address
if (
@JarrydLong
JarrydLong / stop-pmpro-members-from-buying-woocommerce.php
Last active November 26, 2025 07:55 — forked from andrewlimaza/stop-non-pmpro-members-from-buying-woocommerce.php
Make certain WooCommerce products not-purchasable for non-members
<?php
/**
* Stop non-members from purchasing products if they do not have an active Paid Memberships Pro Level.
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function stop_pmpro_members_from_buying_woo( $is_purchasable, $product ) {
// Check if the user has an active membership level.
<?php //do not copy
// Check whether the user has granted Cookiebot consent for cookies beyond necessary.
function my_pmpro_determine_if_set_cookie() {
if ( ! isset( $_COOKIE['CookieConsent'] ) ) {
// User hasn't made a choice — only strictly necessary cookies allowed.
return false;
}
$valid_php_json = preg_replace('/\s*:\s*([a-zA-Z0-9_]+?)([}\[,])/', ':"$1"$2', preg_replace('/([{\[,])\s*([a-zA-Z0-9_]+?):/', '$1"$2":', str_replace("'", '"',stripslashes($_COOKIE["CookieConsent"]))));
<?php //do not copy
/**
* 1. Block checkout immediately if user already has the same level.
*/
function my_pmpro_prevent_same_level_on_load() {
global $pmpro_pages;
// Only run on checkout page and for logged-in users
if ( ! is_page( $pmpro_pages['checkout'] ) || ! is_user_logged_in() ) {
return;
<?php //do not copy
/**
* This recipe forces every checkout to require approval.
*
* Requires the Approvals Add On to be active for this to work.
*
* 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
// Make all fields editable on the orders page in the PMPro dashboard
add_filter( 'pmpro_orders_read_only_fields', function( $fields ) {
return array();
} );
/**
* Register the Stripe Customer ID field for admin profiles
*/
function my_pmpro_add_stripe_customerid_field() {
<?php //do not copy
/**
* This recipe ensures that the member can only hold one level across all groups.
* Signing up for more than one group across any level groups will cancel all other levels.
*
* 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
/**
* Adds the number of seats to the bottom of the confirmation page near the totals
*
* 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
/**
* Override the Geocoding API key to a private key. This helps if you want to restrict
* usage of the Geocoding API key. This key is not public like the JS Map API Key.
*
* To be used with Member Directory 2.1+
*
* 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.