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 customers to select membership duration at checkout. Adjust the amount charged and expiration date of the membership accordingly. | |
| * | |
| * Add this code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
| * | |
| * 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/ | |
| */ |
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 //Do not copy this PHP tag into your code. | |
| /** | |
| * Adds an extra colum to your Memberships > Orders > Export to CSV file. Displays the group discount code used. | |
| * | |
| * Add this code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
| * | |
| * Requires the Paid Memberships Pro Group Discount code Add On to be installed and activated in order to work: | |
| * https://www.paidmembershipspro.com/add-ons/group-discount-codes/ | |
| */ |
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 // be mindful about not duplicating this tag in your customizations plugin. | |
| /** | |
| * This will show the renewal date link within the number of days or less than the members expiration that you set in the code gist below. | |
| * Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
| */ | |
| function show_renewal_link_after_X_days( $r, $level ) { | |
| if ( empty( $level->enddate ) ) { | |
| 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 // Careful not to copy this php tag. | |
| /** | |
| * Add 'pages' for Limit Post Views Add On for Paid Memberships Pro. You may also add your custom post types using this function below. | |
| * Requires the Paid Memberships Pro - Limit Post Types Add On to work: https://www.paidmembershipspro.com/add-ons/pmpro-limit-post-views/ | |
| * Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
| */ | |
| function pmpro_lpv_add_my_post_types( $post_types ) { | |
| // Add pages to post type array to restrict Limit Post Views. | |
| $post_types[] = 'page'; |
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 // Do not copy this tag. | |
| /** | |
| * Replace all spaces with an underscore when new users register for Paid Memberships Pro. | |
| * Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
| */ | |
| function my_custom_user_registration_changes( $userdata ) { | |
| $userdata['user_login'] = str_replace(' ', '_', $userdata['user_login'] ); |
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 // Do not copy this tag | |
| // Use the email address as username with PMPro checkout. You'll also have to hide the username fields at checkout using CSS or a custom checkout page template. | |
| // Paste the code below into a PMPro Customization Plugin: https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
| function my_init_email_as_username() | |
| { | |
| //check for level as well to make sure we're on checkout page | |
| if(empty($_REQUEST['level'])) | |
| return; |
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
| /* | |
| * | |
| * The following CSS code will hide the PMPro username field, label and the required asterisk. | |
| * Add this CSS to your WordPress Customizer's Additional CSS section (WP Dashboard > Appearance > Customizer > Additional CSS) | |
| * Code Recipe intended to be used along with the following gist: https://gist.github.com/travislima/4d599cc0b6169ef7ee7514442f289123 | |
| * | |
| */ | |
| .pmpro_checkout-field-username { | |
| display: none; |
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 | |
| function my_init_email_as_username() | |
| { | |
| //check for level as well to make sure we're on checkout page | |
| if(empty($_REQUEST['level'])) | |
| return; | |
| if(!empty($_REQUEST['bemail'])) | |
| $_REQUEST['username'] = $_REQUEST['bemail']; | |
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 //Do not copy this tag. | |
| // Copy the function below into your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
| // Use the shortcode [membership_level] to display the user's current membership level. | |
| function pmpro_membership_level_shortcode( $atts ){ | |
| if(is_user_logged_in() && function_exists( 'pmpro_hasMembershipLevel' ) && pmpro_hasMembershipLevel()){ | |
| global $current_user; | |
| $current_user->membership_level = pmpro_getMembershipLevelForUser($current_user->ID); | |
| return sprintf(__( "Your current level is: %s", "pmpro" ), $current_user->membership_level->name); |