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 stops users from purchasing a lower level membership through WooCommerce. (Assume lower level ID is '1') | |
* If user has level 2 or 3, stop them from purchasing level 1 membership. | |
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
// Stop users from purchasing a lower membership level via WooCommerce. | |
function pmpro_lower_level_is_purchasable( $is_purchasable, $product ) { |
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
/** | |
* Autocomplete orders with only virtual products. | |
* From the 2nd edition of Building Web Apps with WordPress | |
* https://bwawwp.org | |
*/ | |
function autocomplete_virtual_orders($order_id) { | |
//get the existing order | |
$order = new WC_Order($order_id); | |
//assume we will autocomplete |
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
/* | |
Don't allow early renewals for certain levels. | |
Change the level IDs in the $pmpro_non_renewal_levels global array, then | |
add this code to your active theme's functions.php or a custom plugins. | |
*/ | |
//define levels in global | |
global $pmpro_non_renewal_levels; | |
$pmpro_non_renewal_levels = array(1,2,3); //change this to the level IDs of the levels you don't want users to renew for |
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_pmpro_disable_member_emails($recipient, $email) | |
{ | |
$user = get_user_by('login', $email->data['user_login']); | |
$level = pmpro_getMembershipLevelForUser($user->ID); | |
$disabled_levels = array(1,2,3); //update this to include ids of all levels you want to disable emails for | |
if(!empty($level) && !empty($level->id) && in_array($level->id, $disabled_levels)) | |
$recipient = NULL; | |
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 function allows you to restrict a single WooCommerce product to non-members (disables add to cart button) | |
* Price will still be displayed. | |
* Add the following code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function hide_add_to_cart_for_non_members( ){ |
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 | |
/** | |
* Stop existing members from changing levels when purchasing a product on WooCommerce. | |
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function woo_dont_apply_level_for_existing_members() { | |
if ( pmpro_hasMembershipLevel( '1' ) ) { | |
remove_action( 'woocommerce_order_status_completed', 'pmprowoo_add_membership_from_order' ); |
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
/* | |
Don't let exisisting members checkout for free level. | |
*/ | |
function my_pmpro_registration_checks($okay) | |
{ | |
//only check if things are okay so far | |
if($okay) | |
{ | |
global $pmpro_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
/** | |
* Based on the Register Helper example. | |
* We've added a "buddypress" option for each field | |
* set to the XProfile name we used when setting up | |
* the fields in the BuddyPress extended profile. | |
* If the PMPro BuddyPress Add On is activated | |
* then the fields will be synchronized. | |
* Register Helper: https://www.paidmembershipspro.com/add-ons/pmpro-register-helper-add-checkout-and-profile-fields/ | |
* PMPro BuddyPress: https://www.paidmembershipspro.com/add-ons/buddypress-integration/ | |
*/ |
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 | |
/** | |
* 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. | |
*/ | |
/** |
OlderNewer