Skip to content

Instantly share code, notes, and snippets.

@mircobabini
mircobabini / pmpro-conpd-avoid-complete-cancellation.php
Last active January 16, 2025 17:45
PMPro snippet to disable the "Cancel" button when the auto-renew option is turned off.
<?php
/**
* Remove "Cancel" button for cancelled subscriptions.
*
* The user is still able to cancel auto-renew, but can't completely cancel the membership.
*/
add_filter( 'pmpro_member_action_links', function ( $pmpro_member_action_links ) {
global $current_user;
// bail if cancel link has been removed by someone else
@kimcoleman
kimcoleman / my_pmpro_show_time_on_expiration_date.php
Last active August 6, 2021 23:26
Show the expiration time for a member's level on the Membership Account page.
<?php
/**
* Show the expiration time for a member's level on the Membership Account page.
* Useful for sites that offer hourly membership.
* Requires PMPro v2.6+
*
* 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.
*
*/
@andrewlimaza
andrewlimaza / pmpro-canada-tax-checkout.php
Created July 22, 2021 08:45
Add Canadian Tax to PMPro checkout
<?php
/**
* Add 13% tax to all Canadian customers checking out for a membership level.
* To add this code to your site, please follow this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function customtax_pmpro_tax_ca($tax, $values, $order) {
if ( $_SESSION['bcountry'] == 'CA' || $_REQUEST['bcountry'] == 'CA' ) {
$tax = round( (float) $values[price] * 0.13, 2 );
}
return $tax;
@ideadude
ideadude / my_pmpro_checkout_level.php
Last active December 5, 2021 13:07 — forked from strangerstudios/my_pmpro_checkout_level.php
Increase price at checkout if a certain value (e.g. added via PMPro Register Helper) is set.
<?php
/**
* If a user checked option1, then add $100 to the price.
*/
function my_pmpro_checkout_level($level) {
if( ! empty( $_REQUEST['option1'] ) || ! empty( $_SESSION['option1'] ) ) {
$level->initial_payment = $level->initial_payment + 100;
//$level->billing_amount = $level->billing_amount + 100; //to update recurring payments too
}
@dparker1005
dparker1005 / expiry_log.php
Last active April 18, 2022 18:13
Creates a log at /paid-memberships-pro/logs/level-change.txt for whenever a membership is expired.
<?php
// Copy from below here...
/*
* Creates a log at /paid-memberships-pro/logs/level-change.txt for whenever a
* membership is expired.
*/
function my_pmpro_pre_membership_expiry_log( $user_id, $membership_id ) {
global $wpdb;
<?php
/**
* This code recipe will create a shortcode that returns an image based on the level selected.
*
* 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-sub-delay-add-on.php
Last active April 19, 2021 14:25 — forked from andrewlimaza/remove-sub-delay-add-on.php
Remove subscription delay for any previous member for PMPro.
<?php
/**
* Once a user checks out for a level, it will add usermeta to the user's account.
* This will then remove any subscription delay for that member in the future, even if the user cancels and then re-signs up.
*/
// Update level meta everytime a user changes their level to ensure they are blocked from subscription delays.
function my_pmpro_trial_used( $level_id, $user_id ) {
update_user_meta( $user_id, "pmpro_trial_level_used", "1" );
}
<?php
/*
* Creates a custom merge field in MailChimp.
*/
function my_pmpro_mailchimp_merge_fields( $merge_fields ) {
$merge_fields[] = array(
'name' => 'GOAL',
'type' => 'text'
);
<?php
/**
* Geocodebilling fields when adding a member using the Add Member From Admin Add On
*
* 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
/**
* Send the user's email address through to Zapier on updated_order action
*
* 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/
*
*/