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 | |
/* | |
This code handles loading a file from one or more protected directories. | |
This is a variation of the code presented here: | |
https://www.paidmembershipspro.com/locking-non-wordpress-files-folders-paid-memberships-pro/ | |
(!) Be sure to change the $protected_directories arary below. | |
(!) Add this code to a code snippet or custom plugin. | |
(!) You should have a corresponding bit of code in your Apache .htaccess file | |
to redirect files to this script. You need one line per protected dir. | |
### |
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 | |
// This is an excerpt from *some of* the custom pricing logic we had running on our site to support legacy prices and sales. | |
// Our current custom pricing script is about 140 lines long. | |
/* | |
If purchasing PMPro Plus and they've had plus or core in the past, | |
calculate the appropriate price. | |
*/ | |
if($level->id == 20 && is_user_logged_in()) { | |
// If the user has a current subscription, use the billing amount on file. | |
$user_level = pmpro_getMembershipLevelForUser(); |
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 | |
/** | |
* Allow other business email addresses for PMPro IPN Messages. | |
* To add this code to your site you may follow this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function my_pmpro_ipn_check_receiver_email($check, $email) { | |
if ( in_array( '[email protected]', $email ) ) { //change email here to the old email | |
$check = true; | |
} |
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 | |
/** | |
* Disable the wp_password_change_notification_email email in WordPress. | |
* Add this code into a custom plugin or code snippet. | |
*/ | |
function disable_wp_password_change_notification_email( $email ) { | |
// Removing the recipient email, disables the email. | |
$email['to'] = ''; | |
return $email; |
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 | |
/** | |
* Add this code into a Code Snippet and set the option to | |
* "run only once". Then click the play button from the Snippets | |
* page to run this script. | |
* These meta keys: address, city_name, state_name, country_name, postal_code, and phone_no | |
* will become: pmpro_baddress1, pmpro_bcity, pmpro_bstate, pmpro_bcountry, pmpro_bzipcode, and pmpro_bphone | |
*/ | |
global $wpdb; | |
$sqlQuery = "UPDATE $wpdb->usermeta SET meta_key = 'pmpro_baddress1' WHERE meta_key = 'address'"; |
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 | |
/** | |
* Show the next payment date instead of the expiration date | |
* for the !!membership_expiration!! email var if it's blank. | |
* Add this code into a custom plugin or Code Snippet. | |
* More information on how to add code snippets here: https://www.paidmembershipspro.com/how-to-add-code-to-wordpress/ | |
*/ | |
function my_email_var_membership_expiration( $data, $email ) { | |
if ( empty( $data['membership_expiration'] ) ) { | |
$user = get_user_by( 'email', $data['user_email'] ); |
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
/** | |
* Make country and state dropdowns select2 fields. | |
* Requires both the pmpro-state-dropdowns and | |
* pmpro-register-helper plugins to be active. | |
* | |
* Add this to a custom plugin or code snippet. | |
* More info here: https://www.paidmembershipspro.com/how-to-add-code-to-wordpress/ | |
*/ | |
function my_make_country_and_state_select2() { | |
if ( ! is_admin() ) { |
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 | |
/** | |
* Add "select all" option inside the Require Membership box | |
* 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_add_select_all_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
/** | |
* Hide course content from non-members. | |
* By default, PMPro Courses allows non-members to see the "content" of a course. | |
* Lessons are still hidden. By setting this filter to false, non-members will | |
* see the restricted view on the single course page. | |
*/ | |
add_filter( 'pmpro_courses_show_course_content_to_nonmembers', '__return_false' ); |
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 | |
/** | |
* If a user checked option1, then add $100 to the price. | |
*/ | |
function my_pmpro_checkout_level($level) { | |
if( ! empty( $_REQUEST['option1'] ) || ! empty( $_SESSION['option1'] ) ) { | |
$level->initial_payment = $level->initial_payment + 100; | |
//$level->billing_amount = $level->billing_amount + 100; //to update recurring payments too | |
} |