Skip to content

Instantly share code, notes, and snippets.

strangerstudios / pmpro_international_address_hooks.php
Last active Oct 14, 2018
Using Paid Memberships Pro hooks to enable international addresses
View pmpro_international_address_hooks.php
Add this code to your theme's functions.php file to update the checkout page to support international credit cards.
First we need to enable international addresses. We just use the pmpro_international_addresses hook and return true.
This will add a "countries" dropdown to the checkout page.
function my_pmpro_international_addresses()
strangerstudios / pmpro-redirect-non-members.php
Created Nov 2, 2011
Paid Memberships Pro Redirect Non-members to Login/Homepage
View pmpro-redirect-non-members.php
Redirect to login or homepage if user is logged out or not a member
Add this code to your active theme's functions.php file.
function my_template_redirect()
global $current_user;
$okay_pages = array(pmpro_getOption('billing_page_id'), pmpro_getOption('account_page_id'), pmpro_getOption('levels_page_id'), pmpro_getOption('checkout_page_id'), pmpro_getOption('confirmation_page_id'));
strangerstudios / gist:1389944
Created Nov 23, 2011
Paid Memberships Pro Extra Checkout/Profile Fields Example
View gist:1389944
Adding First and Last Name to Checkout Form
//add the fields to the form
function my_pmpro_checkout_after_password()
$firstname = $_REQUEST['firstname'];
strangerstudios / gist:1421978
Created Dec 2, 2011
Paid Memberships Pro Different Payment Options at Checkout for One Level
View gist:1421978
PMPro Example Offering Monthly and Annual Options on Checkout Page
This code assumes your levels have an annual recurring cost.
The first function converts your annual prices into monthly prices.
function my_getMonthlyPriceFromAnnualPrice($price)
//divide by 10 and round down to nearest dollar
return floor($price / 10);
strangerstudios / gist:1453435
Created Dec 9, 2011
PMPro Disable Membership Dropdown on Profile Page For Users with Gateway Subscriptions
View gist:1453435
Disable the membership level dropdown in the admin if the user has a subscription at the gateway.
This will keep admins from accidentally cancelling subscriptions.
Note: Requires PMPro version 1.3.7+
function my_pmpro_profile_show_membership_level($show, $user)
global $wpdb;
//if the user's membership level is attached to a gateway, disable this field
$last_invoice = new MemberOrder();
strangerstudios / gist:1602202
Created Jan 12, 2012
Paid Memberships Pro and WP e-Commerce Integration Example
View gist:1602202
Paid Memberships Pro/WP e-Commerce Integration
This group of functions will add a secure sign up link to the confirmation message for a specific product setup with WP E-commerce.
The session id from the order is passed to the PMPro checkout form, and will allow registration for a membership level that is otherwise disabled.
Once the user registers, the session id is added to the usermeta table as pmpro_sessionid_used so the session id can only be used once.
The Paid Memberships Pro plugin (v1.3.8 or higher) must be enabled.
strangerstudios / gist:1633637
Last active Sep 29, 2015
Locking Down bbPress Forums using Paid Memberships Pro
View gist:1633637
UPDATE: This gist is no longer needed.
The better way to integrate PMPro and bbPress is to the use the pmpro-bbpress plugin,
which is now available in the WordPress repository:
strangerstudios / gist:1663916
Created Jan 23, 2012
Restrict Access to WordPress Pages Within a Time Frame Using Paid Memberships Pro
View gist:1663916
Functions to give access to certain pages within a timeframe.
Set the $pages and $levels arrays.
function my_pmpro_has_membership_access_filter($hasaccess, $mypost, $myuser, $post_membership_levels)
$pages = array(214); // page ids
$levels[1] = array("2012-01-01", "2012-04-01"); // $level[level_id] = array(start_date, end_date);
$levels[2] = array("2012-02-01", "2012-05-01"); // date format is YYYY-MM-DD
strangerstudios / gist:1894897
Created Feb 23, 2012
Adding Shipping Address to Paid Memberships Pro
View gist:1894897
Plugin Name: PMPro Shipping
Plugin URI:
Description: Add shipping to the checkout page and other updates.
Version: .2.1
Author: Stranger Studios
Author URI:
Note that this plugin requires PMPro 1.3.19 or higher to function fully.
strangerstudios / gist:1974258
Created Mar 4, 2012
Samples Checkout Template for Paid Memberships Pro
View gist:1974258
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.
You can’t perform that action at this time.