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 | |
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_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 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 | |
/** | |
* 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 my_pmpro_hide_discount_code_for_level( $show ) { | |
if ( empty( $_REQUEST['level'] ) ) { | |
return false; | |
} | |
if ( 1 === absint( $_REQUEST['level'] ) || 2 === absint( $_REQUEST['level'] ) ) { // 1,2 is the level ID. | |
return false; | |
} | |
return $show; | |
} |
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 pmprovat_required_vat_fields_submission( $value ) { | |
global $pmpro_msg, $pmpro_msgt; | |
$vat_number = sanitize_text_field( $_REQUEST['vat_number'] ); | |
if ( empty( $vat_number ) ) { | |
$pmpro_msg = 'VAT is required'; | |
$pmpro_msgt = 'pmpro_error'; | |
} | |
return $value; | |
} |
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() ) { | |
$pmpro_pages = array(); | |
$pmpro_pages[] = pmpro_getOption( 'account_page_id' ); | |
$pmpro_pages[] = pmpro_getOption( 'billing_page_id' ); | |
$pmpro_pages[] = pmpro_getOption( 'cancel_page_id' ); | |
$pmpro_pages[] = pmpro_getOption( 'invoice_page_id' ); | |
if ( ! isset( $_REQUEST['level'] ) ) { | |
$pmpro_pages[] = pmpro_getOption( 'checkout_page_id' ); |
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_add_discount_code_js() { | |
?> | |
<script> | |
jQuery('body').on('DOMSubtreeModified', '#pmpro_level_cost', function(){ | |
setTimeout( function() { | |
var html = jQuery( '#pmpro_level_cost' ).html(); | |
if ( jQuery( '#pmpro_payment_information_fields' ).is(':visible') == false ) { | |
jQuery( '.pmpro_discount_code_status' ).html( html ); | |
} else { |
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_add_discount_code( $atts ) { | |
if ( function_exists( 'pmprosm_getCodeByUserID' ) && is_user_logged_in() ) { | |
global $current_user; | |
$code_id = pmprosm_getCodeByUserID( $current_user->ID ); // Replace $current_user->ID with sponsoree ID. | |
if ( $code_id ) { | |
$discount_code = pmprosm_getDiscountCodeByCodeID( $code_id ); | |
if ( isset( $discount_code->code ) ) { | |
return $discount_code->code; | |
} |