Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MaryOJob/e46cf0e813cd6df01655b4145a26ed2c to your computer and use it in GitHub Desktop.
Save MaryOJob/e46cf0e813cd6df01655b4145a26ed2c to your computer and use it in GitHub Desktop.
Remove PMPro Gift Aid text from checkout page for specified levels in the $no_gift_aid_level_ids variable.
<?php
/**
* Remove the gift aid text from the checkout page for specified membership 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/
*/
function my_pmproga_remove_level_cost_text() {
global $pmpro_level, $pmpro_pages;
$no_gift_aid_level_ids = array( 2, 3 );
// bail if if not on checkout page or gift aid not active
if ( ! function_exists( 'pmproga_pmpro_checkout_after_level_cost' ) || ! is_page( $pmpro_pages['checkout'] ) ) {
return;
}
if ( ! empty( $pmpro_level ) ) {
$level_id = $pmpro_level->id;
} elseif ( ! empty( $_REQUEST['level'] ) ) {
$level_id = $_REQUEST['level'];
} else {
$level_id = 0;
}
if ( in_array( $level_id, $no_gift_aid_level_ids ) ) {
// remove level cost text
remove_action( 'pmpro_checkout_after_level_cost', 'pmproga_pmpro_checkout_after_level_cost' );
}
}
add_action( 'wp', 'my_pmproga_remove_level_cost_text' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment