Skip to content

Instantly share code, notes, and snippets.

View JarrydLong's full-sized avatar

Jarryd Long JarrydLong

  • Paid Memberships Pro
  • South Africa
  • 09:02 (UTC +02:00)
  • X @jarrydlong
View GitHub Profile
@JarrydLong
JarrydLong / gist:3bdb5a280d56e695c2a7de96d93136cc
Created September 21, 2016 18:32 — forked from mikejolley/gist:3b37b9cc19a774665f31
Example instance based shipping method
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Sample instance based method.
*/
class WC_Shipping_Test_Method extends WC_Shipping_Method {
@JarrydLong
JarrydLong / init_test_stripe.php
Created February 21, 2020 08:22 — forked from strangerstudios/init_test_stripe.php
Test a Stripe Webhook Event with WordPress and Paid Memberships Pro
/*
Test Stripe webhook events
Add to a custom plugin, then visit /?teststripe=1
*/
function init_test_stripe() {
if(!empty($_REQUEST['teststripe'])) {
$_REQUEST['event_id'] = 'evt_9ktqwT5xFlKNOp'; //EDIT THIS to be the ID of an actual recurring payment event in your account
require_once(PMPRO_DIR . "/services/stripe-webhook.php");
@JarrydLong
JarrydLong / pmprorh-init-buddypress-fields.php
Last active February 24, 2020 10:36 — forked from pbrocks/pmprorh-init-buddypress-fields.php
Example of defining PMPro Register Helper Fields Synchronized to BuddyPress XProfile Fields
<?php
/**
* Based on the Register Helper example.
* We've added a "buddypress" option for each field
* set to the XProfile name we used when setting up
* the fields in the BuddyPress extended profile.
* If the PMPro BuddyPress Add On is activated
* then the fields will be synchronized.
* Register Helper: https://www.paidmembershipspro.com/add-ons/pmpro-register-helper-add-checkout-and-profile-fields/
* PMPro BuddyPress: https://www.paidmembershipspro.com/add-ons/buddypress-integration/
function disqus_embed($disqus_shortname) {
global $post;
wp_enqueue_script('disqus_embed','http://'.$disqus_shortname.'.disqus.com/embed.js');
echo '<div id="disqus_thread"></div>
<script type="text/javascript">
var disqus_shortname = "'.$disqus_shortname.'";
var disqus_title = "'.$post->post_title.'";
var disqus_url = "'.get_permalink($post->ID).'";
var disqus_identifier = "'.$disqus_shortname.'-'.$post->ID.'";
</script>';
@JarrydLong
JarrydLong / my_pmpro_bp_lockdown_all_bp.php
Created April 6, 2020 06:54 — 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.
@JarrydLong
JarrydLong / my_pmpro_email_checkout_renewal.php
Created April 10, 2020 09:42 — forked from strangerstudios/my_pmpro_email_checkout_renewal.php
Use a custom checkout_renewal.html email template for renewal purchases in Paid Memberships Pro
/*
Use a custom checkout_renewal.html email template for renewals.
Add this code to a custom plugin.
Make sure there is a folder /email/ in the plugin folder.
Add a file /email/checkout_renewal.html in that email folder.
*/
function my_pmpro_email_checkout_renewal($email) {
@JarrydLong
JarrydLong / my_pmprowc_free_shipping.php
Last active January 18, 2023 13:49 — forked from strangerstudios/my_pmprowc_free_shipping.php
Give members of specific level IDs Free Shipping in your WooCommerce store.
/*
* Give members of level 1 or 2 Free Shipping when free shipping is available (must set free shipping as an option in store settings).
* Change $pmprowc_free_shipping_levels = array(1,2); to include level IDs that receive free shipping
*/
function my_pmprowc_free_shipping( $rates, $package ) {
$pmprowc_free_shipping_levels = array( '1', '2' );
$free_shipping_key = "";
foreach( $rates as $key => $val ){
if( strpos( $key, 'free_shipping' ) !== false ){
@JarrydLong
JarrydLong / my_pmpro_aweber_custom_fields.php
Last active May 7, 2020 08:13 — forked from strangerstudios/my_pmpro_aweber_custom_fields.php
Send custom fields from WordPress to AWeber through the PMPro AWeber addon. Your fields must be created already in AWeber and also stored as user meta for the users. Add this code to your active theme's functions.php or a custom plugin.
<?php
/*
Send custom fields from WordPress to AWeber through the PMPro AWeber addon.
Your fields must be created already in AWeber and also stored as user meta for the users.
Add this code to your active theme's functions.php or a custom plugin.
*/
function my_pmpro_aweber_custom_fields($fields, $user)
{
if( !empty( $_REQUEST["phone"] ) ){
$fields['phone'] = $_REQUEST["phone"];
@JarrydLong
JarrydLong / pmpro-restrict-countries.php
Last active May 29, 2020 16:21 — forked from strangerstudios/pmpro-restrict-countries.php
Only allow for the countries in the $restricted_countries array
/**
* Only sell to specific countries by adding in the 'allowed' countries' in
* the $restricted_countries array.
*
* 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.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_init()
@JarrydLong
JarrydLong / pmpro-customizations.php
Last active October 21, 2020 07:24 — forked from gausam/pmpro-customizations.php
Allow users to use the trial level only once.
<?php
/*
Plugin Name: PMPro Customizations
Plugin URI: https://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Customizations for my Paid Memberships Pro Setup
Version: .1
Author: Paid Memberships Pro
Author URI: https://www.paidmembershipspro.com
*/