Created
March 6, 2020 20:26
-
-
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.
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 | |
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