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
<?php | |
/** | |
* Change the pricing of a membership level based on the level of user. | |
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function my_charge_discount_for_level( $level ) { | |
// If the user does not have a level, bail. | |
if( ! pmpro_hasMembershipLevel() ){ |
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 only allow users that are 18 years or older to signup on checkout. | |
* This requires a custom 'date' field using Register Helper. | |
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function custom_pmpro_validate_user_age( $okay ) { | |
if( ! $okay ) { |
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 active theme's functions.php or custom plugin. | |
/** | |
* Capture time when a user viewed a post only. | |
* Do not capture admin views, only users. | |
* Stores an array as $array['username'] => timestamp. | |
*/ | |
function wll_save_when_viewed() { |
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 | |
/** | |
* Adds a link to BBPress topics for current user on their Paid Memberships Pro Account Page. | |
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
* www.paidmembershipspro.com | |
*/ | |
function pmpro_add_link_to_account_page() { | |
global $current_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
<?php | |
/** | |
* This will show a member number on the membership card for Paid Memberships Pro. Please read all comments below! | |
* This requires the following - https://www.paidmembershipspro.com/generate-a-unique-member-number-for-display-on-membership-account-confirmation-email-and-more/ | |
* At the time of this writing, created a custom page template and added in hook "do_action( 'pmpro_membership_card_additional_fields', $pmpro_membership_card_user );" to the relevant area. | |
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
* www.paidmembershipspro.com for help. | |
*/ | |
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 | |
/** | |
* Show the time of checkout on Paid Memberships Pro Invoices. | |
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
* See date parameters available to adjust time/date - http://php.net/manual/en/function.date.php#refsect1-function.date-parameters | |
* www.paidmembershipspro.com | |
*/ | |
function pmpro_time_for_invoice( $invoice ) { | |
echo '<li><strong>Time of Checkout: </strong>' . date_i18n( "H:i", $invoice->timestamp ) . '</li>'; |
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 | |
/** | |
* Send validation email when assigning a membership level to a user using PHP code. | |
* Extended from example - https://www.paidmembershipspro.com/give-users-a-default-membership-level-at-registration/ | |
* Adjust code accordingly to your needs, add to PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
add_filter("pmpro_login_redirect", "__return_false"); | |
function my_pmpro_default_registration_level( $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 | |
/** | |
* Remove the Captcha field for particular membership level. | |
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function remove_pmpro_recaptcha() { | |
// Assume user is checking out for level 5. Change according to level you would like to hide the Recaptcha field. |
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 | |
/** | |
* Close comments for non-members. Non-members will still be able to read the comments. | |
* Add this function to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function pmpro_close_comments_non_members() { | |
if( !pmpro_hasMembershipLevel() ) { | |
$r = false; | |
}else{ |