Skip to content

Instantly share code, notes, and snippets.

@renventura
Created March 6, 2020 20:26
Show Gist options
  • Save renventura/a68854b5cfe7f571f107d9b749360404 to your computer and use it in GitHub Desktop.
Save renventura/a68854b5cfe7f571f107d9b749360404 to your computer and use it in GitHub Desktop.
Runs some checks on the post before applying the MemberPress rule. This allows for excluding posts from a rule based on any custom criteria.
<?php
add_filter( 'mepr-pre-run-rule-content', 'cp_maybe_show_content_last_chance', 10, 2 );
/**
* Runs some checks on the post before applying the MemberPress rule.
* This allows for excluding posts from a rule based on any custom criteria.
*
* @param boolean $apply Whether to apply the rule
* @param object $post Post object
*
* @return boolean
*/
function cp_maybe_show_content_last_chance( $apply, $post ) {
// If the post has a category with a slug of "free", we don't want to apply the rule (show the content)
if ( has_category( 'free', $post ) ) {
return false;
}
// Return the default
return $apply;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment