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 | |
| } |
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 | |
| /** | |
| * Look up the label of an option for a Register Helper field. | |
| * @param $field_name The name of the field (user meta key) | |
| * @param $option_key The key of the option in the fields options array. | |
| * @returns The label for the field or "N/A" if none found. | |
| */ | |
| function my_get_rh_option_label( $field_name, $option_key ) { | |
| global $pmprorh_registration_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
| /** | |
| * Sort BuddyPress members by PMPro membership level. | |
| * Add this code as a code snippet or in a custom plugin. | |
| * https://www.paidmembershipspro.com/how-to-add-code-to-wordpress/ | |
| */ | |
| function my_sort_bp_members_list( $query ) { | |
| global $wpdb; | |
| $query->uid_clauses['select'] .= " LEFT JOIN $wpdb->pmpro_memberships_users mu ON u.user_id = mu.user_id AND mu.status = 'active' "; | |
| $query->uid_clauses['orderby'] = str_replace( 'ORDER BY', 'ORDER BY mu.membership_id DESC, ', $query->uid_clauses['orderby'] ); | |
| } |
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 | |
| /** | |
| * Change the billing amount and cycle number/period for a user's active membership. | |
| * This is useful if the number is out of alignment with the gateway. | |
| * Change the variables under "change this stuff" | |
| * Then visit /wp-admin/?my_fix_billing_amount=1 as an admin. | |
| * Deactivate this snippet after running. | |
| */ | |
| function my_fix_billing_amount() { | |
| global $wpdb; |
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 | |
| /** | |
| * When PMPro users cancel or expire, they are shown on the | |
| * cancelled, expired, and "old" members lists. | |
| * However, if an old user is given a default/free level later, | |
| * then they are not considered old, cancelled, or expired anymore. | |
| * | |
| * You may still want to see those users on the old users lists | |
| * so you can follow up to get them back into paid accounts. | |
| * This code does that. |
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
| add_filter( 'pmpro_roles_exclude_other_pmpro_roles', '__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
| /** | |
| * Change the "IMPORTANT!" confirmation text when using PMPro and the Email Confirmation Add On. | |
| * Add this code into a custom plugin or code snippet. | |
| * Be sure to change the translated lines below to the language and words you want. | |
| * https://www.paidmembershipspro.com/how-to-add-code-to-wordpress/ | |
| */ | |
| function my_pmpro_email_confirmation_text( $translated_text, $text, $domain ) { | |
| // Ignore strings for other plugins. | |
| if ( $domain != 'pmpro-email-confirmation' ) { | |
| return $translated_text; |
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
| /** | |
| * Include this code in your custom WordPress plugin | |
| * to load your own versions of the PMPro page templates. | |
| * To override the cancel.php template, place your own | |
| * cancel.php template in a folder like this: | |
| * ../plugins/yourpluginslug/templates/cancel.php | |
| * | |
| * Using priority 100 will make sure this runs after | |
| * other code using the smae hook. For example, | |
| * it will run later than the Reason for Cancelling Add On |