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 | |
// Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
function my_init() | |
{ | |
global $allowed_countries; | |
//specify the countries allowed to signup. The key is the level id. | |
$allowed_countries = array( |
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
/* | |
Set random order "code" to equal the order ID | |
It is important to keep the prefix (PMPRO-) below or change it to something else with a non-number in it. | |
If a code is all numeric, PMPro will go into an infinite loop when a new order is created. | |
*/ | |
function my_pmpro_random_code($code, $order) | |
{ | |
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 | |
/* | |
Change term "membership" to "subscription" for plugin generated text | |
*/ | |
function my_pmpro_gettext_membership($translated_text, $text, $domain) | |
{ | |
if($domain == "paid-memberships-pro") | |
{ | |
$translated_text = str_replace("Membership", "Subscription", $translated_text); | |
$translated_text = str_replace("membership", "subscription", $translated_text); |
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: PMPro Customizations | |
Plugin URI: https://www.paidmembershipspro.com/wp/pmpro-customizations/ | |
Description: Customizations for my Paid Memberships Pro Setup | |
Version: .1 | |
Author: Paid Memberships Pro | |
Author URI: https://www.paidmembershipspro.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
/* | |
When users cancel (are changed to membership level 0) we give them another "cancelled" level. | |
Can be used to downgrade someone to a free level when they cancel. | |
Will allow members to the "cancel level" to cancel from that though. | |
*/ | |
function my_pmpro_after_change_membership_level_default_level($level_id, $user_id) | |
{ | |
//Level ID of membership that you will allow level cancellation on. (Assume this is a free level or lower level than level ID 2 - see line 26) | |
$cancel_level_id = 1; |
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
1. cmd+shift+p | |
2. Type phpcs and install it | |
3. Preferences > Package Settings > PHP Code Sniffer > Settings - User |
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' to 'Subscription' for Paid Memberships Pro. | |
function my_gettext_membership( $translated_text, $text, $domain ) { | |
if( "paid-memberships-pro" == $domain ) { | |
$translated_text = str_replace( "Membership Level", "Subscription", $translated_text ); | |
$translated_text = str_replace( "membership level", "subscription", $translated_text ); | |
$translated_text = str_replace( "membership", "subscription", $translated_text ); | |
$translated_text = str_replace( "Membership", "Subscription", $translated_text ); | |
} | |
return $translated_text; | |
} |
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
/* | |
Automatically generate password on checkout page. | |
Note: if you want to remove the entire user area and generate usernames and passwords, simply set the pmpro_skip_account_fields filter to return false. | |
Use the intstructions here (http://www.paidmembershipspro.com/documentation/advanced-techniques/templates/) to add a checkout page template with the password fields removed. | |
Uncheck the "Default WP notification email. (Recommended: Leave unchecked. Members will still get an email confirmation from PMPro after checkout.)" option in the PMPro Emails Settings tab. | |
*/ | |
function my_generate_passwords() |
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 | |
/* | |
* Add this code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
* Allows customers to select membership duration at checkout. Adjusts the amount charged and expiration date of the membership accordingly. | |
* Requires the Paid Memberships Pro Register Helper Add On to be installed and activated in order to work - https://www.paidmembershipspro.com/add-ons/pmpro-register-helper-add-checkout-and-profile-fields/ | |
*/ | |
function my_pmprorh_init() { |
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
/* | |
This code will create a content filter for all pages and posts to remove access to posts that were published before a member's join date. Only posts or pages which require membership will be hidden. Note that pages and posts that require membership will still be hidden from non-members regardless of the publish date. | |
The params passed are: | |
$hasaccess - (bool) what PMPro thinks about whether the user has access | |
$thepost - (post object) the post being checked, usually the current post | |
$theuser - (user object) the user being checked, usually the current user | |
$post_membership_levels - (array of levels) the levels this post requires (if any) | |
*/ | |
add_filter("pmpro_has_membership_access_filter", "hide_old_posts_from_members", 10, 4); |