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
/* | |
Override the discount code given to sponsored members. | |
This recipe makes any sponsored members with level 2 expire in 2 days. | |
The 'discount_code' array supports the following attributes: | |
code_id, level_id, initial_payment, billing_amount, cycle_number, cycle_period, billing_limit, | |
trial_amount, trial_limit, expiration_number, expiration_period | |
Make sure that strings in the _period values are wrapped in single quotes, e.g. 'expiration_period' => "'Year'" | |
*/ |
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
/* | |
Show sponsored seats on the account page in PMPro settings and on other selected pages. | |
Useful for multi-language sites that have different account pages per language. | |
Requires PMPro and Sponsored Seats Add On. | |
*/ | |
function my_pmprosm_the_content_account_page($content) | |
{ | |
global $post, $pmpro_pages, $current_user, $wpdb; | |
/* |
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
/* | |
Restrict membership access based on parent category | |
*/ | |
function category_restrictions($hasaccess, $mypost, $myuser, $post_membership_levels) | |
{ | |
global $post, $current_user; | |
$categories = wp_get_post_categories($mypost->ID); | |
$restrict = false; |
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 | |
/** | |
* This checks to see if the user has a 'pending' check order and will deny access whever member content is called. | |
* Add this code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function pmpro_deny_if_user_is_pending( $hasaccess, $post, $user, $levels ) { | |
$order = new MemberOrder(); | |
$order->getLastMemberOrder( $user->ID, array( 'pending', '', 'check' ) ); |
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
// change !!membership_cost!! email variable to refer to current level cost, only when checking out with paypal | |
function my_pmpro_email_membership_cost( $data, $email ) { | |
global $pmpro_levels; | |
// are we on the paypal ipnhandler page? if not, stop | |
if( !isset( $_SERVER["REQUEST_URI"] ) || ( strpos( $_SERVER["REQUEST_URI"], "/admin-ajax.php?action=ipnhandler" ) === false )) | |
return $data; | |
$level_id = $data['membership_id']; | |
$current_level = $pmpro_levels[$level_id]; | |
$data['membership_cost'] = pmpro_getLevelCost( $current_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 | |
/** | |
* Make PMPro MailChimp compatible with PMPro Email Confirmation | |
*/ | |
// Don't subscribe to MailChimp if user is not validated. | |
function my_pmproec_pmpro_after_change_membership_level($level_id, $user_id) { | |
if( function_exists('pmproec_isEmailConfirmationLevel') && pmproec_isEmailConfirmationLevel($level_id) ) { | |
$validation_key = get_user_meta($user_id, "pmpro_email_confirmation_key", true); |
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
// customize the HTML/styling of links in PMPro-generated emails | |
function my_pmpro_change_email_link_styling( $data, $email ){ | |
/*--- An array of variable names. Change or add to this to style different links. | |
default options: 'invoice_link', 'levels_link', 'login_link' ---*/ | |
$links_to_change = array( 'invoice_link', 'login_link' ); | |
$newdata = []; | |
foreach( $data as $variable => $value ) { | |
if( in_array( $variable, $links_to_change) && strpos( $value, "http" ) !== false ) { |
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
// always show renew links for certain levels if the member already has that level. | |
function my_pmpro_always_show_renew_levels( $show, $level ){ | |
/*--- change this line to the levels you want to show a renew link---*/ | |
$show_levels = array( 1, 2 ); | |
if( in_array( $level->id, $show_levels ) ) { | |
$show = true; | |
} |
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
function my_gettext_pmpro_hide_view_membership_options($translated_text, $text, $domain) | |
{ | |
if($domain == "paid-memberships-pro" && $text == "View all Membership Options" ) | |
$translated_text = ""; | |
return $translated_text; | |
} | |
add_filter('gettext', 'my_gettext_pmpro_hide_view_membership_options', 10, 3); |
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
// example of adding Javascript to run after the checkout button is clicked | |
function my_pmpro_js_on_submit() { | |
?> | |
<script> | |
jQuery(document).ready( function(){ | |
jQuery("#pmpro_form").submit( function(){ | |
alert("hello world!"); | |
}); | |
}); | |
</script> |