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 | |
// Exclude pending and denied members from BuddyPress directory. | |
function my_pmpro_bp_bp_pre_user_query_construct( $query_array ) { | |
// Only apply this to the directory. | |
if ( 'members' != bp_current_component() ) { | |
return; | |
} | |
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 PayPal order description to "billing_name - level_name". | |
*/ | |
function my_pmpro_paypal_level_description( $description, $level_name, $order, $site_name ) { | |
// Get name from billing address. | |
$name = $order->billing->name; | |
$description = "{$name} - {$level_name}"; |
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 | |
/** | |
* Don't allow renewal for same level if user has an active subscription. | |
*/ | |
// Hide the Renew link. | |
function hide_renewal_links_for_some_levels($r, $level) { | |
// Get user's last order. |
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 | |
/** | |
* Hide old posts from new members, except for specific categories. | |
*/ | |
add_filter( 'pmpro_has_membership_access_filter', 'hide_old_posts_from_members', 10, 4 ); | |
function hide_old_posts_from_members( $hasaccess, $thepost, $theuser, $post_membership_levels ) { | |
global $wpdb; | |
// if PMPro says false already, return false |
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 | |
/** | |
* Save PayPal payer email in usermeta. | |
*/ | |
function my_http_api_debug( $response, $context, $class, $r, $url ) { | |
global $current_user; | |
// Only continue for PayPal requests. |
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 trial if user has cancelled order for same level. | |
* Add code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function pmpro_remove_trial_for_existing_members( $level ) { | |
$order = new MemberOrder(); | |
if ( $order->getLastMemberOrder( null, 'cancelled', $level->id ) ) { | |
$level->trial_limit = 0; |
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 | |
/* | |
* Search member directory for custom user meta passed in via query parameters. | |
* | |
* (e.g. www.example.com/directory?company=abc+company) | |
*/ | |
function my_pmpro_member_directory_sql( $sqlQuery ) { | |
// usermeta key to search. |
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 checks to see if the user has a 'pending' check order and will deny access whever member content is called. | |
* Add this code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function pmpro_deny_if_user_is_pending( $hasaccess, $post, $user, $levels ) { | |
// Only continue if post or page already requires access. | |
if ( empty( $levels ) ) { | |
return $hasaccess; |
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 | |
// Don't apply set expiration date if renewing. | |
function my_pmpro_checkout_level( $checkout_level ) { | |
// Get current level. | |
$user_level = pmpro_getMembershipLevelForUser(); | |
if ( ! empty( $user_level ) && $user_level->id == $checkout_level->id ) { | |
// Remove Set Expiration Date filters. | |
remove_filter("pmpro_checkout_level", "pmprosed_pmpro_checkout_level"); | |
remove_filter('pmpro_discount_code_level', 'pmprosed_pmpro_checkout_level', 10, 2); |
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 | |
/** | |
* Prorate initial payment based on subscription delay. | |
* | |
* Requires Subscription Delay and Proration Add Ons. | |
*/ | |
function my_pmpro_checkout_level( $level ) { | |
// Only continue if Subscription Delays and Proration Add Ons are activated. |