Created
February 8, 2023 12:55
-
-
Save ipokkel/14c132f5b96a20ee59cf46f71e23b5f7 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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