Skip to content

Instantly share code, notes, and snippets.

View andrewlimaza's full-sized avatar

Andrew Lima andrewlimaza

View GitHub Profile
@andrewlimaza
andrewlimaza / my_pmpro_bp_approvals_directory_init.php
Created May 13, 2020 11:41 — forked from messica/my_pmpro_bp_approvals_directory_init.php
Hide pending/denied members from BuddyPress member directory.
<?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;
}
@andrewlimaza
andrewlimaza / pmpro_clear_enddates.sql
Last active April 17, 2020 09:51 — forked from strangerstudios/pmpro_clear_enddates.sql
Clear out end dates for active subscriptions since the subs are managed by the gateway.
# 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
####
@andrewlimaza
andrewlimaza / functions.php
Last active April 14, 2020 06:59 — forked from lukecav/functions.php
WordPress Multisite: Password Reset on a Subsite.
<?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
*
@andrewlimaza
andrewlimaza / my_pmpro_bp_lockdown_all_bp.php
Created April 4, 2020 14:08 — forked from ideadude/my_pmpro_bp_lockdown_all_bp.php
Allow non-members to view the BuddyPress profile pages even if you are "locking down all of BuddyPress".
/**
* 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.
@andrewlimaza
andrewlimaza / my_pmpro_forward_ipn.php
Last active October 19, 2021 12:58 — forked from ideadude/my_pmpro_forward_ipn.php
Forward PMPro PayPal IPNs to another domain
/**
* 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.
@andrewlimaza
andrewlimaza / wc-disable-product-repeat-purchase.php
Created March 9, 2020 07:13 — forked from bekarice/wc-disable-product-repeat-purchase.php
Disables Repeat Purchase for a particular WooCommerce product
<?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 ) {
@andrewlimaza
andrewlimaza / my_ipn_redirect.php
Last active December 10, 2019 09:30 — forked from strangerstudios/my_ipn_redirect.php
Redirect IPN URL Example
<?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');
@andrewlimaza
andrewlimaza / my_first_last_display_name.php
Last active April 16, 2021 06:15 — forked from kimcoleman/my_first_last_display_name.php
Set Display Name on Membership Checkout and for BuddyPress Name field.
<?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 ) ) {
@andrewlimaza
andrewlimaza / register-helper-test1.php
Last active November 21, 2019 13:31 — forked from MaryOJob/register-helper-test1.php
Adding Five Custom Fields to PMPro Accounts Page
<?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" ) ) {
@andrewlimaza
andrewlimaza / my_wp_bouncer_number_simultaneous_logins.php
Last active October 31, 2019 09:13 — forked from strangerstudios/my_wp_bouncer_number_simultaneous_logins.php
Change WP Bouncer limit based on user's membership level.
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;
}