Skip to content

Instantly share code, notes, and snippets.

View ideadude's full-sized avatar

Jason Coleman ideadude

View GitHub Profile
@ideadude
ideadude / init_test_braintree_webhook.php
Created March 5, 2021 16:36
Testing the PMPro Braintree using the signature and payload from a webhook log.
<?php
/**
* Add this function into a customizations plugin
* and then visit yoursite.com/wp-admin/?test_braintree_webhook=1 from a browser.
*/
function init_test_braintree_webhook() {
if(!empty($_REQUEST['test_braintree_webhook'])) {
define('PMPRO_BRAINTREE_WEBHOOK_DEBUG', true);
$_POST['bt_signature'] = 'putthesignaturefromthewebhookloghere';
@ideadude
ideadude / pmpro-australia-gst.php
Last active January 19, 2023 09:27 — forked from strangerstudios/pmpro-australia-gst.php
Paid Memberships Pro - Australia GST
<?php
/*
Plugin Name: Paid Memberships Pro - Australia GST
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-australia-gst/
Description: Apply Australia GST to Checkouts with PMPro
Version: .1
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
*/
/*
@ideadude
ideadude / my_show_member_badge_in_bbpress_replies.php
Created January 19, 2021 21:17
Display a member's badge in bbPress replies when using Paid Memberships Pro and the Member Badges Add On.
<?php
/**
* Display a member's badge on replies.
* Requires the Member Badge Add On https://www.paidmembershipspro.com/add-ons/member-badges/
* Add this code to a Code Snippet or custom plugin.
* https://www.paidmembershipspro.com/how-to-add-code-to-wordpress/
*/
function my_show_member_badge_in_bbpress_replies() {
// Make sure pmpro and bbpress are active.
if ( ! defined( 'PMPRO_VERSION' ) || ! class_exists( 'bbPress' ) ) {
@ideadude
ideadude / pmpro_nginx_restrict_docs.conf
Last active April 17, 2021 00:16
Locking down only PDF,DOC,DOCX,PPT,ZIP files with Paid Memberships Pro using NGINX
rewrite ^\/wp-content\/uploads\/(.*[\.pdf|\.doc|\.docx|\.ppt|\.zip])$ /wp-content/plugins/paid-memberships-pro/services/getfile.php last;
@ideadude
ideadude / pmpro_nginx.conf
Last active January 9, 2025 11:15
NGINX rule to lock down files with Paid Memberships Pro
rewrite ^/wp-content/uploads/(.*)$ /wp-content/plugins/paid-memberships-pro/services/getfile.php last;
@ideadude
ideadude / my_redirect_buddypress_registration_to_pmpro_levels.php
Created January 8, 2021 11:53
Redirect BuddyPress registration to the PMPro levels page.
<?php
/**
* Redirect BuddyPress registration to the PMPro levels page.
* Add this code into a Code Snippet or custom plugin.
* https://www.paidmembershipspro.com/how-to-add-code-to-wordpress/
* Note that this gist will redirect users to the level pages.
* You can adjust it to link to checkout for a specific level
* or, if you have only one level, adjust it to link to the
* checkout page, which will default to the first available level.
*/
@ideadude
ideadude / pmpro-cancel-on-billing-failure.php
Last active February 2, 2021 11:20 — forked from strangerstudios/pmpro-cancel-on-billing-failure.php
Cancel PMPro subscriptions when a recurring payment fails.
<?php
/**
* Cancel subscriptions when a recurring payment fails.
* You should also use the PMPro Email Templates Add On to edit the
* default billing_failure.html email to mention that users are cancelled upon failure.
*/
function my_cancel_subscriptions_on_any_failed_payment( $order ) {
pmpro_cancelMembershipLevel( $order->membership_id, $order->user_id );
}
add_action( 'pmpro_subscription_payment_failed', 'my_cancel_subscriptions_on_any_failed_payment' );
@ideadude
ideadude / my_original_sub_order_col.php
Created October 26, 2020 18:57
Add a column to the PMPro orders table that shows the original subscription order.
<?php
/**
* Add a column to the PMPro orders table that shows the original subscription order.
* Requires PMPro 2.5+
* Add this code to a Code Snippet or custom plugin.
*/
function my_original_sub_order_col_header($order_ids) {
?>
<th>Original Order</th>
<?php
@ideadude
ideadude / my_redirect_away_from_docs.php
Last active October 27, 2020 23:49
Hide BuddyPress docs from members of some levels when using Paid Memberships Pro.
/**
* Hide docs from some levels.
* Make sure to adjust the pmpro_hasMembershipLevel check below
* to use the IDs of your levels which SHOULD have access to view members.
* Everyone else will be redirected to the restricted access or levels page.
*
* Copy this code into a custom plugin or Code Snippet.
*/
function my_redirect_away_from_docs() {
// Bail if PMPro and BuddyPress aren't active.
@ideadude
ideadude / my_redirect_away_from_member_pages.php
Created October 12, 2020 21:20
Hide individual BuddyPress member pages from members of some levels when using Paid Memberships Pro.
/**
* Hide individual member pages from some levels.
* Make sure to adjust the pmpro_hasMembershipLevel check below
* to use the IDs of your levels which SHOULD have access to view members.
* Everyone else will be redirected to the restricted access or levels page.
*
* Copy this code into a custom plugin or Code Snippet.
*/
function my_redirect_away_from_member_pages() {
// Bail if PMPro and BuddyPress aren't active.