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
# oops I had PMPro setup with recurring subscriptions AND expiration dates | |
# I really didn't need the expiration date because the subscription is managed by the gateway | |
# if payment fails, the gateway will try again based on its settings | |
# and when the gateway gives up, it will tell PMPro through IPN/webhook to cancel the subscription | |
# If I have expiration dates setup for recurring subscription, PMPro is going to cancel those subscriptions | |
# whether they pay or not. So I need to edit the level and remove the expiration date AND | |
# run this script to clear out the end dates for active subscriptions. | |
#### | |
# BACK UP YOUR DATABASE FIRST | |
#### |
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 | |
/** | |
* Password reset on sub site (1 of 4) | |
* Replace login page "Lost Password?" urls. | |
* | |
* @param string $lostpassword_url The URL for retrieving a lost password. | |
* @param string $redirect The path to redirect to. | |
* | |
* @return string | |
* |
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
/** | |
* This gist will disable the default behavior in PMPro BuddyPress 5.2.5 or earlier, | |
* which would redirect users away from the BP profile pages if you had | |
* "all of BuddyPress" locked down for non-members or members of a specific level. | |
* | |
* We might address this in future versions of the Add-On, but for now, you can use | |
* this gist. Add it to a Code Snippet or a custom plugin. | |
*/ | |
// First disable the default PMPro BuddyPress behavior. |
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
/** | |
* Forward PMPro PayPal IPNs to another domain. | |
* Each domain will process the IPNs. The IPN handlers should be setup to ignore | |
* messages that aren't for that site. PMPro does this. | |
* This is useful if you have 2 different sites using the same PayPal account | |
* and the IPN is setup to go to a PMPro site. | |
* Add this to a custom plugin on the PMPro site the IPN hits. | |
* Update the domain/url to the IPN you want to forward to. | |
* The pmprodev_gateway_debug_setup check makes sure this DOESN'T run if you have the | |
* PMPro Toolkit plugin enabled, i.e. you are on a staging site. |
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 // only copy if needed! | |
/** | |
* Disables repeat purchase for the product | |
* | |
* @param bool $purchasable true if product can be purchased | |
* @param \WC_Product $product the WooCommerce product | |
* @return bool $purchasable the updated is_purchasable check | |
*/ | |
function sv_disable_repeat_purchase( $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 | |
function my_ipn_redirect() { | |
if( ! empty($_REQUEST['option'] ) && $_REQUEST['option'] == 'rs_membership' && ! empty( $_REQUEST['paypalpayment'] ) && defined('PMPRO_DIR') ) { | |
require_once(PMPRO_DIR . "/services/ipnhandler.php"); | |
exit; | |
} | |
} | |
add_action('init', 'my_ipn_redirect'); |
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 | |
/** | |
* Set Display Name on Membership Checkout and for BuddyPress Name field. | |
*/ | |
function my_first_last_display_name( $user_id, $morder ) { | |
// Get user's first and last name. | |
$first_name = get_user_meta( $user_id, 'first_name', true ); | |
if ( ! empty( $first_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 | |
/** | |
* Register Helper example for five fields. This is a test Register Helper example. | |
* Please add the below code to your custom plugin or Code Snippets Plugin by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function my_pmprorh_init() { | |
//don't break if Register Helper is not loaded | |
if ( ! function_exists( "pmprorh_add_registration_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
function my_wp_bouncer_number_simultaneous_logins($num) { | |
// Bail if PMPro not activated or function not available. | |
if ( ! function_exists( 'pmpro_hasMembershipLevel' ) ) { | |
return $num; | |
} | |
if ( pmpro_hasMembershipLevel( '1' ) ) { | |
$num = 1; | |
} |