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 | |
/** | |
* Remove capabilities from membership manager role. | |
* | |
* @param array $caps Array of capabilities. | |
* | |
* @return array new array of capabilities. | |
*/ | |
function pmpromm_remove_caps( $caps ) { | |
$caps = array( |
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 | |
function pmpro_redirect_account_page_to_login() { | |
if ( ! is_user_logged_in() ) { | |
if ( is_page( 'membership-account' ) ) { | |
$referer = get_permalink( get_queried_object_id() ); | |
$redirect_url = add_query_arg( | |
array( | |
'redirect_to' => $referer, | |
'reauth' => 1, | |
), |
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 | |
function pmpro_levels_exclude_page() { | |
if ( is_single( 'hello-world' ) ) { | |
remove_action( 'wp', 'pmpro_lpv_wp' ); | |
add_filter( 'pmpro_has_membership_access_filter', '__return_true' ); | |
} | |
} | |
add_action( 'wp', 'pmpro_levels_exclude_page', 9 ); |
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 | |
function my_pmpro_show_discount_code( $show ) { | |
if ( empty( $_REQUEST['discount_code'] ) || is_user_logged_in() ) { | |
$show = false; | |
} | |
return $show; | |
} | |
add_filter( 'pmpro_show_discount_code', 'my_pmpro_show_discount_code' ); |
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 | |
function pmpro_change_theme_per_level( $theme ) { | |
if ( ! function_exists( 'pmpro_hasMembershipLevel' ) ) { | |
return $theme; | |
} | |
if ( pmpro_hasMembershipLevel( 1 ) ) { | |
return 'twentyeleven'; | |
} elseif ( pmpro_hasMembershipLevel( 2 ) ) { | |
return 'twentyfourteen'; | |
} |
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 merges any discount codes that a user has used to the MailChimp export. | |
* | |
* 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_pmpro_mailchimp_listsubscribe_fields( $fields, $user ) { |
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 | |
global $pmpro_addon_pages_for_courses; | |
// 28 is the page ID; 24 is the course ID. | |
// 30 is the page ID; 26 is the course ID. | |
$pmpro_addon_pages_for_courses = array( | |
28 => 24, | |
30 => 26, | |
); | |
function pmproap_learndash_template_redirect() | |
{ |
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 redirect non members away from a page | |
* according to the current URL address | |
* | |
* 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/ | |
*/ |
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 | |
function pmpro_custom_pages_shortcode_confirmation( $content ) { | |
if ( is_user_logged_in() ) { | |
if ( class_exists( 'PMPro_Approvals' ) ) { | |
global $current_user; | |
$approval_levels = PMPro_Approvals::getApprovalLevels(); | |
foreach ( $approval_levels as $level ) { | |
if ( ! PMPro_Approvals::isApproved( $current_user->ID, $level ) ) { | |
wp_logout(); | |
break; |
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 | |
/* | |
Show an invite code on the account page. | |
*/ | |
function pmproio_custom_the_content_account_page($content) | |
{ | |
global $current_user, $pmpro_pages, $post; | |
// First check if PMPro is active. | |
if ( ! function_exists( 'pmpro_hasMembershipLevel' ) ) { | |
return $content; |