Last active
July 25, 2023 14:35
-
-
Save JarrydLong/6b71cc4f83a0ff27c9b3ecc42ca43a3a to your computer and use it in GitHub Desktop.
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 | |
/** | |
* This recipe will allow you to control content with all membership levels. | |
* | |
* 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 mypmpro_elementor_levels( $levels ){ | |
$levels['ALL'] = __( 'All Membership Levels' ); | |
return $levels; | |
} | |
add_filter( 'pmpro_elementor_levels_array', 'mypmpro_elementor_levels', 10, 1 ); | |
function mypmpro_elementor_has_access( $access, $element, $restricted_levels ){ | |
if( in_array( 'ALL', $restricted_levels ) ){ | |
if( pmpro_hasMembershipLevel() ){ | |
return true; | |
} | |
} | |
return $access; | |
} | |
add_action( 'pmpro_elementor_has_access', 'mypmpro_elementor_has_access', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment