Skip to content

Instantly share code, notes, and snippets.

View andrewlimaza's full-sized avatar

Andrew Lima andrewlimaza

View GitHub Profile
@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_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 / 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 / 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 / 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 / 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;
}
<?php
// Copy from below here
function my_pmproarc_remove_checkbox_with_discount_code() {
?>
<script>
jQuery(document).ready(function() {
// After any AJAX call...
jQuery( document ).ajaxComplete(function() {
@andrewlimaza
andrewlimaza / my_pmpro_custom_tax_example.php
Last active October 22, 2020 12:36 — forked from strangerstudios/my_pmpro_custom_tax_example.php
Custom tax structure for Paid Memberships Pro where level 1 has no tax and all other levels have 7.25% tax if country is IT (Italy)
<?php
/*
Custom Tax Example.
- Requires PMPro 1.3.13 or higher.
- Leave the tax fields blank in the payment settings.
- Level 1 has no tax applied, all other levels have tax applied.
- Other levels have 22% tax for IT customers only.
- We update the price description to include the tax amount.
*/
function my_pmpro_tax( $tax, $values, $order ) {
<?php
/**
* Creates shipping address fields for 'child' accounts when using the Sponsored/Group Members for Paid Memberships Pro.
* This requires the following attribute 'sponsored_accounts_at_checkout' => true for checkout.
* PLEASE NOTE: Using the Register Helper Add On (or similar) may interfere with this code if field names match.
*
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* Skill Required: Advanced.
*/
<?php
/**
* This recipe Adds !!company!!/!!phone!! as an available variable for use in Paid Memberships Pro emails.
* When the variable is empty it will display nothing instead of the !!company!!/!!phone!! email variable
*
* Notice the array key does not include the !!s
*
* 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.