Last active
January 25, 2022 14:25
-
-
Save kimwhite/e96a55c7ac5b1823bb71457fb7b5d15c to your computer and use it in GitHub Desktop.
Give access to specific Addon Packages by Level
This file contains 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 // do not copy this line. | |
/** | |
* Give user's with a certain level ID 4 free access to all some Addon Packages content. | |
* | |
* 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_pmproap_access_for_levels( $levels ) { | |
global $post; | |
$level_2_addon_packages = array( 30,53 ); //add the page ids for your Addon Packages | |
$level_3_addon_packages = array( 30 ); //add the page ids for your Addon Packages | |
if ( in_array( $post->ID, $level_2_addon_packages )) { | |
$levels[] = 2; //change the level ids here | |
} | |
if ( in_array( $post->ID, $level_3_addon_packages )) { | |
$levels[] = 3; //change the level ids here | |
} | |
return $levels; | |
} | |
add_filter( "pmproap_all_access_levels", "my_pmproap_access_for_levels" ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment