Skip to content

Instantly share code, notes, and snippets.

@strangerstudios
strangerstudios / gist:1389944
Created November 23, 2011 21:17
Paid Memberships Pro Extra Checkout/Profile Fields Example
<?php
/*
Adding First and Last Name to Checkout Form
*/
//add the fields to the form
function my_pmpro_checkout_after_password()
{
if(!empty($_REQUEST['firstname']))
$firstname = $_REQUEST['firstname'];
@strangerstudios
strangerstudios / gist:1453435
Created December 9, 2011 21:45
PMPro Disable Membership Dropdown on Profile Page For Users with Gateway Subscriptions
/*
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
strangerstudios / gist:1663916
Created January 23, 2012 15:50
Restrict Access to WordPress Pages Within a Time Frame Using Paid Memberships Pro
/*
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
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:2035922
Created March 14, 2012 11:37
Using WordPress HTTPS with Paid Memberships Pro
<?php
/*
Some WordPress HTTPS Fixes
In general, if you are using Paid Memberships Pro, you do not want to use the WordPress HTTPS plugin. PMPro will also secure your links.
If you are still receiving SSL errors on your checkout page, try setting the "nuclear" option on the Payment Gateway and SSL settings page of PMPro (v 1.3.19+)
If you want to continue using WordPress HTTPS for some reason, add this code to your theme's functions.php or somewhere else to force Paid Memberships Pro
to follow WordPress HTTPS' rules for redirecting, etc.
*/
//if WordPress HTTPS is activated allow their force_ssl custom field to replace the besecure one
function pmpro_WordPressHTTPSForceSSL($besecure)
@strangerstudios
strangerstudios / gist:2185226
Last active April 16, 2021 01:15
Delete the WordPress User When a Paid Memberships Pro Member Cancels His Account
/*
Requires PMPro v1.4+
Code to delete WP user accounts when a member cancels their PMPro account.
Users are not deleted if:
(1) They are not cancelling their membership (i.e. $level_id != 0)
(2) They are an admin.
(3) The level change was initiated from the WP Admin Dashboard
(e.g. when an admin changes a user's level via the edit user's page)
*/
function my_pmpro_after_change_membership_level($level_id, $user_id)
@strangerstudios
strangerstudios / gist:2232405
Created March 29, 2012 01:56
Pay Per Post for WordPress with Paid Memberships Pro
<?php
/*
Limiting posts per user.
Enable the Paid Memberships Pro plugin and then add this code to your functions.php or as a stand alone plugin.
Be sure to read through this code carefully. Update each function to suit your needs.
This code has not been tested. Feel free to post issues in the comments.
*/
//increment post limit when checking out
function my_pmpro_after_checkout($user_id)
{
@strangerstudios
strangerstudios / gist:2323424
Created April 6, 2012 22:07
Hide the Level Description from the Checkout Page with Paid Memberships Pro
<?php
/*
In Paid Memberships Pro v1.4+ the memberhsip level description is shown on the checkout page. This code will remove the description on the checkout page.
*/
function my_pmpro_remove_description_from_checkout_page($level)
{
$level->description = "";
return $level;
}
add_filter("pmpro_checkout_level", "my_pmpro_remove_description_from_checkout_page");
@strangerstudios
strangerstudios / gist:2930051
Last active April 16, 2021 23:36
Use Paid Memberships Pro Filter to Force HTTPS on All Pages
/*
Add this into a custom plugin or your active theme's functions.php
*/
add_filter("pmpro_besecure", "__return_true");
@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
*/