Skip to content

Instantly share code, notes, and snippets.

@strangerstudios
strangerstudios / my_pmpro_registration_checks.php
Created April 14, 2015 16:08
Require a certain level before registering for another level with Paid Memberships Pro.
/*
Require a certain level before registering for another level.
Add this code to your active theme's functions.php or
a custom plugin.
*/
function my_pmpro_registration_checks($okay)
{
//only check if things are okay so far
if($okay)
{
@strangerstudios
strangerstudios / pmpro-customizations.php
Last active December 5, 2023 12:19
A blank plugin file for customizations to your Paid Memberships Pro setup.
<?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
*/
@strangerstudios
strangerstudios / pmpro_getMembershipLevelForUser.php
Created March 23, 2015 15:04
Show a member's membership level with Paid Memberships Pro.
if(is_user_logged_in() && function_exists('pmpro_hasMembershipLevel') && pmpro_hasMembershipLevel())
{
global $current_user;
$current_user->membership_level = pmpro_getMembershipLevelForUser($current_user->ID);
echo 'Membership Level: ' . $current_user->membership_level->name;
}
@strangerstudios
strangerstudios / pmpro-change-level-id.sql
Last active November 10, 2023 18:26
SQL to change the id of a Paid Memberships Pro level from old_id to new_id. Please BACKUP YOUR DATABASE FIRST, make sure to change the DB table names to match your prefix, and make sure that there is not another level with
# change these vars
SET @old_id = 2;
SET @new_id = 1;
# change the db table prefix here
UPDATE IGNORE wp_pmpro_membership_levels SET id = @new_id WHERE id = @old_id;
UPDATE IGNORE wp_pmpro_discount_codes_levels SET level_id = @new_id WHERE level_id = @old_id;
UPDATE IGNORE wp_pmpro_membership_orders SET membership_id = @new_id WHERE membership_id = @old_id;
UPDATE IGNORE wp_pmpro_memberships_categories SET membership_id = @new_id WHERE membership_id = @old_id;
UPDATE IGNORE wp_pmpro_memberships_pages SET membership_id = @new_id WHERE membership_id = @old_id;
@strangerstudios
strangerstudios / my_init_change_pmpro_content_filter_priority.php
Last active November 8, 2023 09:40
Tell PMPro to filter the content a bit later.
/*
Tell PMPro to filter the_content a bit later.
This will sometimes fix issues where theme or plugin elements (e.g. videos)
are not being filtered by PMPro. Note that this sometimes will cause
some things (e.g. share links) to be filtered that you don't want to be
filtered... and sometimes edits to the theme or a child theme are
required to get the desired effect.
Add this to your active theme's fucntions.php or a custom plugin.
@strangerstudios
strangerstudios / oudc_pmpro_registration_checks.php
Last active November 5, 2023 14:29
Have a discount code only usable for old/expired members in PMPro.
/*
Old Users Discount Code (oudc)
*/
//define the discount code here
define('OUDC_DISCOUNT_CODE', 'abc123'); //change abc123 here to the discount code that is for old members only
//make sure only old members can use a specific discount code
function oudc_pmpro_registration_checks($okay) {
//if something else went wrong, just return $okay
if(!$okay)
@strangerstudios
strangerstudios / pmproet_templates.php
Created June 17, 2017 15:07
Example of using the pmproet_templates filter in the PMPro Email Templates addon to add your own email templates.
/*
If you add this code into a plugin, then the PMPro Email Templates addon
will allow you to set/change the body of the email through its UI.
You can then send an email using this template using code like:
$email = new PMProEmail();
$email->template = 'my_email_template_name';
$email->email = 'email@youaresendingto.com';
$email->send();
@strangerstudios
strangerstudios / pmpro_expiration_date_shortcode.php
Last active October 31, 2023 06:40
Shortcode to show a member's expiration date with Paid Memberships Pro
/*
Shortcode to show a member's expiration date.
Add this code to your active theme's functions.php or a custom plugin.
Then add the shortcode [pmpro_expiration_date] where you want the current user's
expiration date to appear.
If the user is logged out or doesn't have an expiration date, then --- is shown.
*/
@strangerstudios
strangerstudios / my_pmpro_payment_method.css
Created October 1, 2015 11:52
Adds credit card logos and a PayPal logo to the "Select Payment Method" box on membership checkout.
/* CSS Document */
.pmpro-checkout #pmpro_payment_method span {
display: inline-block;
}
.pmpro-checkout #pmpro_payment_method span a {
background-position: bottom left;
background-repeat: no-repeat;
background-size: contain;
border: none;
display: inline-block;
@strangerstudios
strangerstudios / remove_pmpro_footer_link.php
Created February 9, 2016 21:54
Remove the (hidden as an HTML comment) comment that is added to mark a site as using Paid Memberships Pro