Skip to content

Instantly share code, notes, and snippets.

@ronalfy
Created July 21, 2020 16:56
Show Gist options
  • Save ronalfy/bf70a8a071207d4686e4b2f796752e49 to your computer and use it in GitHub Desktop.
Save ronalfy/bf70a8a071207d4686e4b2f796752e49 to your computer and use it in GitHub Desktop.
Body Class based on Membership Level and Coupon
<?php
/* Code will add CSS class charity-page to the <body> tag when level and discount code are present in the URL */
add_filter( 'body_class', function( $classes ) {
if ( isset( $_REQUEST['level'] ) && isset( $_REQUEST['discount_code'] ) ) {
// Additional checks can be done here to ensure the correct level and discount code value.
$classes[] = 'charity-page';
}
return $classes;
} );
/*
Example CSS in use to hide the pricing fields on the charity page:
body.charity-page #pmpro_pricing_fields {
display: none;
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment