Skip to content

Instantly share code, notes, and snippets.

View kimwhite's full-sized avatar

Kim White kimwhite

View GitHub Profile
<?php // do not copy
/**
* This recipe will display a list of pages/posts that are protected by adding the shortcode `[mypmpro_display_posts]` to a page.
*
* 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/
*/
@kimwhite
kimwhite / add_username_hint_at_checkout.php
Last active March 24, 2025 15:47 — forked from dparker1005/add_username_hint_at_checkout.php
Adds a hint under the "Username" field at checkout.
<?php // do not copy this line.
/**
* This recipe Adds a placeholder hint inside the "Username" field at checkout.
*
* 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/
*/
@kimwhite
kimwhite / my-pmpro-group-account-fix.php
Last active March 18, 2025 13:11
This recipe Adjusts the priority of the Group Account hook on the pmpro_checkout_level filter.
<?php // do not copy this line
/**
* Adjust Group Account Hook Priority for Compatibility with Auto-Renewal Checkbox Add On
*
* This recipe modifies the priority of the Group Account hook on the `pmpro_checkout_level` filter.
* Resolves a conflict when using the Auto-Renewal Checkbox Add On with a Group Leader Account
* to ensure proper functionality at checkout.
*
* For use when using both:
* - Group Accounts Add On: https://www.paidmembershipspro.com/add-ons/group-accounts/
@kimwhite
kimwhite / set-initial-price-for-members.php
Last active February 28, 2025 14:10 — forked from andrewlimaza/set-initial-price-to-0-for-members.php
Set the initial amount to $0 for existing members.
<?php
/**
* Set the initial price to xxx for members only, for specific levels.
*
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_adjust_initial_amount( $level ) {
// Define different prices for specific levels
$level_prices = array(
@kimwhite
kimwhite / my-pmpro-show-specific-countries.php
Last active February 28, 2025 12:40 — forked from ipokkel/my-pmpro-remove-non-default-countries.php
Show specific Country in Billing address Drowndown
<?php
/**
* This recipe is an example of how to keep only specific countries in the dropdown.
* and remove all other countries from the "Country" dropdown select.
*
* The PMPro default country is "US" (United States), to set
* your custom default country, please refer to this article.
* @link https://www.paidmembershipspro.com/change-the-default-country-of-your-membership-website/
*
* For available countries and their shortcode see:
@kimwhite
kimwhite / allow_or_deny_checkout_on_restricted_countries.php
Last active February 27, 2025 12:39 — forked from MaximilianoRicoTabo/allow_or_deny_checkout_on_restricted_countries.php
This gist works over a list of a countries and levels. It restricts the checkout to certain levels to certain countries. Either denying or Allowing
<?php // do not copy this line.
/**
* This recipe allow or deny the checkout of a level to certain countries.
* Modify $restriction_mode to use 'deny' or 'allow'. Modify $restricted_countries using level ids as keys and country codes as values.
*
* 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/
*/
@kimwhite
kimwhite / my_pmprodon_donation_notes.php
Last active February 14, 2025 15:28 — forked from davidmutero/my_pmprodon_donation_notes.php
Donation notes field example for PMPro Donations (Updated).
<?php
/**
* Donation notes.
* Edit the copy below.
* Add to a custom plugin.
* Notes are now saved into the order meta instead of the order notes.
*/
// Show the donation notes field at checkout (Always visible)
@kimwhite
kimwhite / change-set-expiration-date-pmpro-renewal.php
Last active February 13, 2025 15:13 — forked from andrewlimaza/change-set-expiration-date-pmpro-renewal.php
Change Set Expiration Date value for existing members/renewals
<?php
/**
* Changes the Y-M-D value for existing members when using the Set Expiration Date Add On.
* Allows you to extend renewal dates for Set Expiration Dates Add On.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_change_set_expiration_renewal_date( $date ) {
if ( ! function_exists( 'pmpro_getSetExpirationDate' ) ) {
return $date; // Ensure the function exists before using.
<?php
/**
* Customize the 'checkout_free' email template based on membership level.
*
* This function modifies the email subject and body for Level 1, (you can chage the ID)
* while leaving other levels with the default template.
*
* 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.
@kimwhite
kimwhite / my-pmpro-levels-require-dc.php
Last active January 10, 2025 12:49 — forked from strangerstudios/gist:5573829
Paid Memberships Pro customization to only let members of a certain level checkout if a discount code was used.
<? // Updated for Multiple Levels.
/*
Require a discount code for specific membership levels.
Place this code in your active theme's functions.php or a custom plugin.
*/
function my_pmpro_registration_checks_require_code_to_register($pmpro_continue_registration)
{
// Only proceed if registration checks have passed so far
if (!$pmpro_continue_registration) {