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 | |
/* | |
Each user can only use one discount code. | |
Add this to your active theme's functions.php or a custom plugin. | |
*/ | |
function my_pmpro_check_discount_code($okay, $dbcode, $level_id, $code) | |
{ | |
global $wpdb, $current_user; | |
$codes_used = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->pmpro_discount_codes_uses WHERE user_id = '" . $current_user->ID . "'" ); |
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 | |
/** | |
* Redirect non-members (including logged-in non-members) away from restricted pages and to home page. | |
* This allows non-members to access Paid Memberships Pro checkout/levels pages as well as the default WordPress login page. | |
* | |
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function my_redirect_non_members_example() { |
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 will redirect members with level 1 from site.com/page-slug to the home page. | |
* Please adjust accordingly and add to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function redirect_member_from_page_x() { | |
if ( is_page( 'shop' ) && ! pmpro_hasMembershipLevel() ) { | |
wp_redirect( home_url('login') ); //redirect to home page. Change home_url() to home_url( '/page-slug' ) to redirect to specific page. |
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 | |
/** | |
* Use PMPro Register Helper to add PMPro Billing Address fields to the edit user page. | |
*/ | |
/** | |
* show_pmpro_address_fields_on_edit_profile Grabs the values from the billing fields which get filled in during checkout and displays on User Profile. | |
* | |
* @return array Array of Register Helper field objects | |
*/ | |
function show_pmpro_address_fields_on_edit_profile() { |
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 | |
/** | |
* Remove user order manually by adjusting the ID's in the array, or adding them into a | |
* query param by setting it to /?reset_test_accounts=true&accounts=2,3 | |
*/ | |
function pmpro_remove_orders( $user_id = null ){ | |
if( isset( $_REQUEST['reset_test_accounts'] ) && $_REQUEST['reset_test_accounts'] == 'true' ){ | |
global $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
<?php | |
function my_pmpro_term_template_redirect() { | |
global $post; | |
//change category and level ID here | |
if( has_term('PGreen-blog', 'content_type', $post) && 351 == $post->ID && !pmpro_hasMembershipLevel()) | |
{ | |
wp_redirect(pmpro_url('levels')); | |
exit; | |
} | |
} |
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 "Pay by Check" language to "Pay by Bank" | |
Add this code to your active theme's functions.php | |
or a custom plugin. | |
*/ | |
function my_gettext_pay_by_check($translated_text, $text, $domain) | |
{ | |
if($domain == "pmpro-pay-by-check" && $text == "Pay by 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
<?php | |
/* | |
Plugin Name: Paid Memberships Pro - South Africa VAT | |
Plugin URI: TBA | |
Description: Apply South Africa VAT to Checkouts with PMPro | |
Version: .1 | |
Author: Stranger Studios | |
Author URI: http://www.strangerstudios.com | |
*/ | |
/* |
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
/* | |
PMPro percent off discount codes. Adds a text field to the discount code settings to define a percentage off the membership level. This will override any other discount code settings for the level. Currently, only works on initial one-time payments. | |
*/ | |
function pmpropd_pmpro_discount_code_after_level_settings( $code_id, $level ) { | |
$percents = pmpro_getDCPDs( $code_id ); | |
if ( ! empty( $percents [ $level->id ] ) ) { | |
$percent = $percents [ $level->id ]; | |
} else { | |
$percent = ''; |