Last active
April 12, 2021 20:25
-
-
Save kimcoleman/e10ffb75c9561aaad5d8fae4b55a7789 to your computer and use it in GitHub Desktop.
Tell PMPro and PMPro Add On Packages to use the user's current level or a specific level by ID when checking out for an Addon package.
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
/** | |
* Use new pmproap_text_level_id filter to choose the user's currenet level OR a specific level with access. | |
* Update this code as needed and add to a custom plugin. | |
*/ | |
function choose_specific_level_for_addon_packages( $text_level_id, $post_id, $user_id, $post_levels ) { | |
if ( ! pmpro_hasMembershipLevel( $text_level_id, $user_id ) && in_array( 8, $post_levels ) ) { | |
$text_level_id = 8; | |
} | |
return $text_level_id; | |
} | |
add_filter( 'pmproap_text_level_id', 'choose_specific_level_for_addon_packages', 10, 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This recipe is included in the blog post on "Set a Specific Checkout Level When Using Addon Packages" at Paid Memberships Pro here: https://www.paidmembershipspro.com/set-a-specific-checkout-level-when-using-addon-packages/