Skip to content

Instantly share code, notes, and snippets.

View ipokkel's full-sized avatar

Theuns Coetzee ipokkel

View GitHub Profile
<?php //do not copy
/**
* This recipe will automatically populate the PMPro checkout fields Woocommerce field data.
*
* 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/
*/
@ideadude
ideadude / my_pmpro_cancel_levels_one_by_one
Last active February 8, 2022 14:13
When cancelling "all levels" in PMPro, do them one at a time so CONPD works.
<?php
/**
* This gist updates the "cancel all memberships" link on the cancel page
* to pass the level ids into the page instead of "all".
* This will ensure that all the levels are cancelled one by one.
* In addition to sending a separate email for each cancellation,
* this also ensures the $old_level parameter is sent to the
* pmpro_cancelMembershipLevel() function so Add Ons like the
* Cancel on Next Payment Date one continue to work.
*
<?php //do not copy
/**
* This recipe lock members into their existing membership.
* They won't be able to cancel or sign up for a different membership level.
*
* Change lines 19 and 43 to the level ID that requires you to be locked in.
*
* If you don't want to prevent them from cancelling, comment out line 30 with //
*
* You can add this recipe to your site by creating a custom plugin
@andrewlimaza
andrewlimaza / prorate-pmpro-based-on-initial-payment.php
Created January 5, 2022 10:45
Prorate Paid Memberships Pro Checkouts based on initial payments only.
<?php
/**
* Prorate initial payments (only) for Paid Memberships Pro checkouts.
* This will prorate for any active members changing levels. If the level is the same price, it does not prorate to $0.
* If a member is 'downgrading' levels, set the price to $0. (i.e. $10 -> $5 level will set the initial payment to $0).
*
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function pmpro_prorate_levels_price( $level ) {
@andrewlimaza
andrewlimaza / qr-code-pmpro-example.php
Last active May 11, 2022 13:26
QR Code example to return membership information.
<?php
/**
* Returns membership information when scanning QR Code on Membership Card 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_qr_code_example( $member, $option ){
if ( $option == 'other' ){
@ipokkel
ipokkel / example-change-text-for-paid-memberships-pro-with-gettext.php
Created December 16, 2021 07:42
Example code for changing text for the Paid Memberships Pro plugin using the WordPress gettext filter hook.
<?php
/**
* Change the text "Welcome, %s" to "Hello %s" for Paid Memberships Pro
*
* 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/
*/
@ideadude
ideadude / my_add_extra_expiration_warning_templates.php
Last active March 26, 2024 06:44
Send extra expiration warning emails with individual templates when using PMPro and the Extra Expiration Warning Emails add on.
<?php
/**
* Send extra expiration warning emails with individual templates.
* Make sure the Extra Expiration Warning Emails Add On is also active.
* https://www.paidmembershipspro.com/add-ons/extra-expiration-warning-emails-add-on/
*
* Then add this code into a custom plugin or code snippet.
* https://www.paidmembershipspro.com/how-to-add-code-to-wordpress/
*/
// Tell the expiration warnings add on to use our templates.
@andrewlimaza
andrewlimaza / reset-user-to-pending-whenever-imported.php
Created November 10, 2021 12:00
Reset user to pending when importing from CSV.
<?php
/**
* Set the user to "pending" whenever you run an import using the Import Users From CSV Integration for Paid Memberships Pro.
*
* 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/
*/
@andrewlimaza
andrewlimaza / keep-pmpro-member-price-manual-renewal.php
Created November 4, 2021 10:33
Keep pre-existing members on their initial checkout price when renewing their membership level.
<?php
/**
* Keep pre-existing members on their initial checkout price when manually renewing. Grandfather 'old' members when their levels pricing changes.
* Note: This is not needed for recurring membership levels and is designed for levels with an expiration date.
*
* 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/
*/
@andrewlimaza
andrewlimaza / automatically-apply-discount-code-pmpro.php
Last active October 18, 2023 13:24
Automatically apply discount code to checkout for Paid Memberships Pro.
<?php
/**
* Automatically apply a discount code to Paid Memberships Pro checkout.
* Adjust the discount code that should apply to all checkouts.
* If another discount code is set, use that as prefernce.
*
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_apply_discount_code() {