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 | |
/* | |
* Redirects members-only content to the Membership Levels page on the Main Network Site | |
* if a user is logged out or not a member. | |
*/ | |
function my_template_redirect_network_require_membership_access() { | |
if ( function_exists( 'pmpro_has_membership_access' ) && ! pmpro_has_membership_access() ) { | |
wp_redirect( network_site_url( 'levels' ) ); | |
exit; |
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 | |
/** | |
* Adds last payment date and next payment date to the members list and export CSV. | |
* Note that "last payment" value will get the last order in "success", "cancelled", or "" status. (Oddly enough, cancelled here means that the membership was cancelled, not the order.) | |
* | |
* The "next payment" value is an estimate based on the billing cycle of the subscription and the last order date. It may be off from the actual recurring date set at the gateway, especially if the subscription was updated at the gateway. | |
* | |
* 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. |
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 | |
// Copy from below here... | |
/* | |
* Charge different prices for different membership levels. | |
*/ | |
//global var to store the price configurations | |
global $custom_addon_package_prices; | |
$custom_addon_package_prices = 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 | |
// Copy from below here... | |
/** | |
* Remove variable pricing check and hide errors when discount code is applied. | |
* Follow this guide to add this code snippet to your site - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
* Visit www.paidmembershipspro.com for more information. | |
*/ |
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 tracking for Paid Memberships Pro on high traffic sites. | |
* | |
* 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_disable_reporting() { |
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 | |
// Copy from below here... | |
/* | |
* In addition to adding this code to your site, note that | |
* WP Engine also has aggressive caching that your login page | |
* should be excluded from, especially if you experience issues | |
* with your login page. | |
* https://wpengine.com/support/cache/#Cache_Exclusions |
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 | |
/* | |
* Creates a PMPro email shortcode for the sponsored members message to use for greater control over location of message. | |
* Use !!sponsored_message!! in email checkout body to display. | |
* Removes the automatic insertion of message at the top of the email. | |
*/ | |
function my_sponsored_email_shortcode($pmpro_email) | |
{ | |
global $wpdb, $pmprosm_sponsored_account_levels; |
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 | |
/* | |
Only allow users to use the trial level once. | |
Add this code to your active theme's functions.php | |
or a custom plugin. | |
Be sure to change the $trial_level_id variable in multiple places. | |
*/ | |
//record when users gain the trial level | |
function my_pmpro_one_time_trial_level($level_id, $user_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
/* | |
Change cancellation to set expiration date for next payment instead of cancelling immediately. | |
Assumes orders are generated for each payment (i.e. your webhooks/etc are setup correctly). | |
Since 2015-09-21 and PMPro v1.8.5.6 contains code to look up next payment dates via Stripe and PayPal Express APIs. | |
*/ | |
//before cancelling, save the next_payment_timestamp to a global for later use. (Requires PMPro 1.8.5.6 or higher.) | |
function my_pmpro_before_change_membership_level($level_id, $user_id) { | |
//are we on the cancel page? |
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 | |
// Copy from below here | |
/* | |
* Require that a user use a discount code when reigstering for specific levels. | |
*/ | |
function my_pmpro_registration_checks_require_code_to_register( $pmpro_continue_registration ) { | |
$restricted_levels = array( 1, 3 ); // Levels 1 and 3 require a discount code to register | |
global $discount_code, $pmpro_level; |
NewerOlder