Skip to content

Instantly share code, notes, and snippets.

View MaryOJob's full-sized avatar
🏠
Working remotely 😈

Mary Job MaryOJob

🏠
Working remotely 😈
View GitHub Profile
@strangerstudios
strangerstudios / gist:1974258
Created March 4, 2012 18:20
Samples Checkout Template for Paid Memberships Pro
<?php
/*
Template Name: Buy
*/
/*
To make a checkout template for your site and PMPro.
1. Create a template page based on your page.php, single,php, index.php, etc.
2. Find the area where the post_content usually goes.
@strangerstudios
strangerstudios / gist:3100680
Created July 12, 2012 20:18
Hidden Levels for Paid Memberships Pro
<?php
/*
Plugin Name: PMPro Hidden Levels
Plugin URI: http://www.paidmembershipspro.com/pmpro-hidden-levels/
Description: With this plugin, select levels are removed from the levels page but still available for checkout if you visit the checkout URL directly.
Version: .1
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
*/
@strangerstudios
strangerstudios / gist:3678054
Last active August 31, 2020 17:21
Extend Expiration Dates For Renewed Memberships in Paid Memberships Pro
/*
Important note! This code is included in PMPro versions 1.5.7 and later.
Adding this code will add 2x the number of days to the end of the subscription.
*/
//if checking out for the same level, add remaining days to the enddate
function my_pmpro_checkout_level($level)
{
global $pmpro_msg, $pmpro_msgt;
//does this level expire? are they an existing user of this level?
@strangerstudios
strangerstudios / pmpro-cancel-on-billing-failure.php
Last active December 3, 2020 14:30
Cancel PMPro subscriptions when a recurring payment fails.
/*
Cancel subscriptions when a recurring payment fails. As of PMPro version 1.5.9.1, failed payments reported via Stripe webhook, PayPal IPN handler, or Authorize.net silent post kick off the pmpro_subscription_payment_failed action.
Also make sure to edit the default billing_failure.html email to mention that users are cancelled upon failure. To do so, copy paid-memberships-pro/email/billing_failure.html into themes/{active theme}/paid-memberships-pro/email/ and edit the text to suit your need.
Note: This cancels on the first failure. To cancel only when cancelling at Stripe, see this gist: https://gist.github.com/strangerstudios/5093710
*/
function my_pmpro_subscription_payment_failed($order)
{
//cancel the membership
@strangerstudios
strangerstudios / pmpro_birthday_check.php
Created May 20, 2013 12:43
Add a birthday field to the Paid Memberships Pro register/checkout page and check that the age is between 13 and 17.
/*
Add birthday to user signup and check that user is between 13-17.
Will not work with PayPal Standard or PayPal Express.
*/
//birthday fields
function my_pmpro_checkout_after_email()
{
$current_day = date("j");
$current_month = date("M");
@strangerstudios
strangerstudios / update_currency_per_level.php
Created February 4, 2014 15:59
Change currencies depending on Paid Memberships Pro level. Add this code to your active theme's functions.php or a custom plugin. This is just an example that will need to be tweaked for your needs.
/*
Change currencies depending on Paid Memberships Pro level.
Add this code to your active theme's functions.php or a custom plugin.
This is just an example that will need to be tweaked for your needs.
Other places to look into swapping currencies:
* Levels page.
* Invoices page.
* In emails.
* In membership levels table in admin.
@strangerstudios
strangerstudios / my_pmpro_email_recipient.php
Created September 24, 2014 17:43
Disable PMPro Checkout Confirmation Emails
/*
Disable PMPro Checkout Confirmation Emails
Add this code to your active theme's fucntions.php
or a custom plugin.
*/
function my_pmpro_email_recipient($recipient, $email)
{
if(strpos($email->template, "checkout_") !== false)
$recipient = NULL;
@strangerstudios
strangerstudios / my_pmpro_checkout_level_renewal_pricing.php
Created December 28, 2014 20:23
$25 discount when renewing the same level in Paid Memberships Pro
function my_pmpro_checkout_level_renewal_pricing($level)
{
$discount = 25; //change this
if(pmpro_hasMembershipLevel($level->id)) //might want to check for specific levels here
$level->initial_payment = max(0, $level->initial_payment - $discount);
return $level;
}
add_filter('pmpro_checkout_level', 'my_pmpro_checkout_level_renewal_pricing');
@strangerstudios
strangerstudios / pmprobuddy_update_user_meta.php
Last active October 18, 2022 20:48
Sync WordPress user meta fields (e.g. those added by PMPro Register Helper) with BuddyPress profile fields.
/*
Sync PMPro fields to BuddyPress profile fields.
*/
function pmprobuddy_update_user_meta($meta_id, $object_id, $meta_key, $meta_value)
{
//make sure buddypress is loaded
do_action('bp_init');
//array of user meta to mirror
$um = array(
@strangerstudios
strangerstudios / is_user_logged_in_required.php
Last active April 3, 2020 07:12
Make PMPro Register Helper fields required for logged out users only.
if(is_user_logged_in())
$required = false;
else
$required = true;
$fields[] = new PMProRH_Field(
"company", // input name, will also be used as meta key
"text", // type of field
array(
"size"=>40, // input size