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 | |
/** | |
* We can use the pmpro_membership_content_filter filter in | |
* the pmpro_membership_content_filter() function to debug | |
* and see what the $content and $hasaccess vars are set to | |
* at the time of running. | |
* | |
* IMPORTANT: This code will effectively break your site with | |
* the debug info. Only use this for a moment, then deactivate it. | |
* |
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 gist updates the "cancel all memberships" link on the cancel page | |
* to pass the level ids into the page instead of "all". | |
* This will ensure that all the levels are cancelled one by one. | |
* In addition to sending a separate email for each cancellation, | |
* this also ensures the $old_level parameter is sent to the | |
* pmpro_cancelMembershipLevel() function so Add Ons like the | |
* Cancel on Next Payment Date one continue to work. | |
* |
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 | |
/** | |
* Prevent non-members from adding member products to their cart. | |
* This requires the PMPro CPT Add On be installed and | |
* each product should be checked for which levels are required. | |
*/ | |
function my_keep_members_only_products_out_of_carts( $is_purchasable, $product ) { | |
// Not purchasable for some other reason. | |
if( ! $is_purchasable ) { | |
return $is_purchasable; |
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 | |
/** | |
* Also hide members-only "products" CPT from archives. | |
* You must use the PMPro CPT Add On and then check a produc to require membership. | |
* And also set the "Filter searches and archives?" option to Yes in the PMPro advanced settings. | |
*/ | |
function my_hide_members_only_products_from_archives( $post_types ) { | |
if ( ! in_array( 'product', $post_types ) ) { | |
$post_types[] = 'product'; | |
} |
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 phone number to the data array sent to Zapier | |
* when a new PMPro order is made. | |
* | |
* This gist requires the pmpro-zapier plugin. | |
* For information on how to add code snippets: https://www.paidmembershipspro.com/how-to-add-code-to-wordpress/ | |
*/ | |
function my_pmproz_added_order_data_add_phone( $data, $order, $user_id ) { | |
$data['phonenumber'] = get_user_meta( $user_id, 'pmpro_bphone', 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
/* Remove the level fee column */ | |
#pmpro_account-membership table.pmpro_table .pmpro_account-membership-levelfee { | |
display: none; | |
} | |
#pmpro_account-membership table.pmpro_table tr th:nth-child(1) { | |
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 | |
/** | |
* Hide the expiration text on the levels page with PMPro. | |
* Add this code into a custom plugin or code snippet. | |
*/ | |
function my_hide_expiration_text_on_levels_page( $text ) { | |
global $pmpro_pages; | |
if ( ! empty( $pmpro_pages['levels'] && is_page( $pmpro_pages['levels'] ) ) ) { | |
$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
<?php | |
/** | |
* Send extra expiration warning emails with individual templates. | |
* Make sure the Extra Expiration Warning Emails Add On is also active. | |
* https://www.paidmembershipspro.com/add-ons/extra-expiration-warning-emails-add-on/ | |
* | |
* Then add this code into a custom plugin or code snippet. | |
* https://www.paidmembershipspro.com/how-to-add-code-to-wordpress/ | |
*/ | |
// Tell the expiration warnings add on to use our templates. |
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 | |
/** | |
* Automatically approve any previously approved member. | |
* Requires the PMPro Approval Process for Membership Add On - https://www.paidmembershipspro.com/add-ons/approval-process-membership/ | |
* Add this code to your site following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function my_pmpro_automatically_approve_previously_approved( $level_id, $user_id, $cancelled_level ) { | |
if ( ! class_exists( 'PMPro_Approvals' ) ) { |
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
/** | |
* Prorate the initial payment at PMPro checkout based on the day of the month. | |
* You should use the Subscription Delays add on to set your subscription | |
* to delay until Y1-M1-01. | |
*/ | |
function my_pmpro_checkout_level( $level ) { | |
$current_day = date( 'j' ); | |
// Ignore if it's the first of the month. | |
if ( $current_day == 1 ) { |