Skip to content

Instantly share code, notes, and snippets.

@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:3111478
Last active April 23, 2024 12:52
Lockdown BuddyPress with Paid Memberships Pro Example
<?php
/*
Plugin Name: PMPro BuddyPress Customizations
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-buddypress-customizations/
Description: Example code to lock down parts of BuddyPress with PMPro
Version: 0.2
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
*/
/*
@strangerstudios
strangerstudios / my_pmpro_members_list_csv_extra_columns.php
Last active April 7, 2018 21:10
Add Website and Nickname Fields to the Paid Memberships Pro Members List CSV Export
/*
Plugin Name: PMPro Extra Members List CSV Export Columns
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-extra-members-list-csv-export-columns/
Description: Add extra fields to the Paid Memberships Pro Members List CSV Export
Version: .1
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
Notes on use:
@strangerstudios
strangerstudios / gist:3137539
Last active March 28, 2016 18:03
Integrate Paid Memberships Pro with WP Affiliate Platform
<?php
/*
We now maintain this code gist as an addon.
* On GitHub: https://github.com/strangerstudios/pmpro-wp-affiliate-platform
* Our Site: http://www.paidmembershipspro.com/add-ons/plus-add-ons/pmpro-wp-affiliate-platform-integration/
Tips and tricks also maintains a version here:
https://www.tipsandtricks-hq.com/wordpress-affiliate/paid-memberships-pro-wp-affiliate-plugin-integration-873
*/
@strangerstudios
strangerstudios / pmpro-disable-all-emails.php
Created September 7, 2012 16:24
Disable All PMPro Emails
<?php
/*
Plugin Name: PMPro Disable All Emails
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-disable-all-emails/
Description: Disable All PMPro Emails
Version: .1
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
Add this file to your /wp-content/plugins/ folder and then activate it from the Plugins page in your WP admin.
@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 / gist:3700077
Created September 11, 2012 17:32
Allow + in WordPress Usernames
/*
Allow + in usernames
Just add this code to your active theme's functions.php or a custom plugin.
*/
function pmprorh_sanitize_user( $username, $raw_username, $strict = false )
{
//only check if there is a + in the raw username
if(strpos($raw_username, "+") === false)
return $username;
@strangerstudios
strangerstudios / gist:3845777
Created October 6, 2012 18:50
All Access Levels with Paid Memberships Pro and PMPro-Addon-Packages .1.2+
/*
Set levels as "all access levels" so members of these levels will be able to view all Addon Packages.
Requires Paid Memberships Pro and the pmpro-addon-packages plugin.
*/
function my_pmproap_all_access_levels($levels, $user_id, $post_id)
{
//I'm just adding the level, but I could do some calculation based on the user and post id to programatically give access to content
$levels = array(16);
return $levels;
}
@strangerstudios
strangerstudios / gist:4027538
Created November 6, 2012 21:06
Hide the confirm email and confirm password fields from the Paid Memberships Pro checkout page.
/*
Don't show confirm password or email fields on the checkout page.
Add this code to your active theme's functions.php or a custom plugin.
*/
add_filter("pmpro_checkout_confirm_password", "__return_false");
add_filter("pmpro_checkout_confirm_email", "__return_false");
@strangerstudios
strangerstudios / hide_old_posts_from_members.php
Last active May 17, 2021 15:57
Paid Memberships Pro: Hide Old Posts From New Members
/*
This code will create a content filter for all pages and posts to remove access to posts that were published before a member's join date. Only posts or pages which require membership will be hidden. Note that pages and posts that require membership will still be hidden from non-members regardless of the publish date.
The params passed are:
$hasaccess - (bool) what PMPro thinks about whether the user has access
$thepost - (post object) the post being checked, usually the current post
$theuser - (user object) the user being checked, usually the current user
$post_membership_levels - (array of levels) the levels this post requires (if any)
*/
add_filter("pmpro_has_membership_access_filter", "hide_old_posts_from_members", 10, 4);