Skip to content

Instantly share code, notes, and snippets.

View ipokkel's full-sized avatar

Theuns Coetzee ipokkel

View GitHub Profile
@dparker1005
dparker1005 / load-pmpro-stripe-library.php
Last active February 24, 2022 16:49
Make sure that PMPro loads the Stripe library first if other plugins are loading outdated versions on every page load.
<?php
/**
* Make sure that PMPro loads the Stripe library first if other plugins are loading outdated
* versions on every page load. This is a blunt way to address the conflict and should be used
* with caution.
*
* To use, add as a new file in your site's `wp-content/mu-plugins/` folder.
*/
if ( file_exists( dirname( __FILE__ ) . "/../plugins/paid-memberships-pro/includes/lib/Stripe/init.php" ) && ! class_exists( "Stripe\Stripe" ) ) {
@andrewlimaza
andrewlimaza / clear-stripe-level-meta.php
Created February 16, 2022 15:17
Clear Stripe level meta data [Script]
<?php
/**
* Clear any unnecessary Stripe data from level meta table that may be causing checkout issues.
*
* To run this code add it to your WordPress website by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* Once installed, add ?clean_stripe=1 to any URL while logged-in as an admin.
*
* After running this script, please delete it from your site.
*
* @return void
@kimwhite
kimwhite / my-pmpro-addon-package-access.php
Last active January 25, 2022 14:25
Give access to specific Addon Packages by Level
<?php // do not copy this line.
/**
* Give user's with a certain level ID 4 free access to all some Addon Packages content.
*
* 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 / pmpro-addon-packages-woocommerce.php
Last active January 25, 2022 14:17
Add or Remove Addon Package access based on WooCommerce purchased products.
<?php
/**
* Integrate Addon Packages with WooCommerce product purchased (based on the order status).
* Recommended to be used with PMPro WooCommerce to apply a default level for all products that give access to posts (Addon Packages).
*
* To get started, please adjust the $product_ids_to_posts global array which uses a product_id => post_id key/value pair.
* Extend this array for all products that will give access to posts.
*
* Adds access to the post once the order is completed.
* Removes access from the post if the order is set to cancelled, failed or refunded.
<?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/
*/