Skip to content

Instantly share code, notes, and snippets.

@strangerstudios
strangerstudios / nofree_pmpro_email_data.php
Created Dec 6, 2013
Remove the "this membership level is free" language from PMPro member change emails. Any recurring subscription will still be deleted (unless you are doing something else), but that language was confusing in some cases. Add this to a custom plugin or your active theme's functions.php.
View nofree_pmpro_email_data.php
/*
Remove the "This membership is free" text from membership change emails.
*/
function nofree_pmpro_email_data($email_data, $email)
{
if(!empty($email_data['membership_change']))
$email_data["membership_change"] = str_replace(". This membership is free", "", $email_data["membership_change"]);
return $email_data;
}
@strangerstudios
strangerstudios / pmpro-auto-password-generation.php
Created Apr 7, 2013
Auto generate passwords with Paid Memberships Pro
View pmpro-auto-password-generation.php
/*
Automatically generate password on checkout page.
Note: if you want to remove the entire user area and generate usernames and passwords, simply set the pmpro_skip_account_fields filter to return false.
Use the intstructions here (http://www.paidmembershipspro.com/documentation/advanced-techniques/templates/) to add a checkout page template with the password fields removed.
Uncheck the "Default WP notification email. (Recommended: Leave unchecked. Members will still get an email confirmation from PMPro after checkout.)" option in the PMPro Emails Settings tab.
*/
function my_generate_passwords()
@strangerstudios
strangerstudios / my_gettext_pay_by_check.php
Created Jun 29, 2015
Update Pay by Check wording in pmpro-pay-by-check to something else.
View my_gettext_pay_by_check.php
<?php
/*
Change "Pay by Check" language to "Pay by Wire Transfer"
Add this code to your active theme's functions.php
or a custom plugin.
*/
function my_gettext_pay_by_check($translated_text, $text, $domain)
{
if($domain == "pmpropbc" && $text == "Pay by Check")
@strangerstudios
strangerstudios / pmpro_isOrderRecurring.php
Last active May 12, 2020
Perform an action on Paid Memberships Pro (PMPro) recurring orders only.
View pmpro_isOrderRecurring.php
/*
Perform an action on PMPro recurring orders only.
A recurring order here is one that
(1) Has an earlier order with the same subscription_transaction_id.
(2) Is not created at PMPro checkout.
Note that we are checking if function_exists for pmpro_isOrderRecurring incase
we add this to PMPro core. Also note that the $test_checkout param there is used
here to avoid #2 above. So this parameter will check if the currently running PHP
script is being fired at checkout, not necessarily if the order was created at checkout,
@strangerstudios
strangerstudios / pmpro_custom_teaser_text.php
Created Sep 24, 2013
Customize the teaser text (typically set in the advanced options) using filters with Paid Memberships Pro.
View pmpro_custom_teaser_text.php
/*
Edit Teaser Messages Depending on Content
In the example below, we have 3 levels with IDs 1, 2, and 3. Level 1 is a free level.
Level 2 is a paid level. Level 3 is a higher-tiered paid level.
So each level is an upgrade over the other. All level 2 members have access to level 1 content, etc.
When showing teaser text, we check if the current post is available to free members.
If so, we show a link to register for the free level. If not, we show a link to the paid level.
@strangerstudios
strangerstudios / pmpro_order_codes.php
Last active May 7, 2020
Change how codes are generated for orders in Paid Memberships Pro. Add this code to your active theme's functions.php or a custom plugin.
View pmpro_order_codes.php
/*
Set random order "code" to equal the order ID
It is important to keep the prefix (PMPRO-) below or change it to something else with a non-number in it.
If a code is all numeric, PMPro will go into an infinite loop when a new order is created.
*/
function my_pmpro_random_code($code, $order)
{
global $wpdb;
@strangerstudios
strangerstudios / my_pmpro_aweber_custom_fields.php
Created Feb 11, 2014
Send custom fields from WordPress to AWeber through the PMPro AWeber addon. Your fields must be created already in AWeber and also stored as user meta for the users. Add this code to your active theme's functions.php or a custom plugin.
View my_pmpro_aweber_custom_fields.php
/*
Send custom fields from WordPress to AWeber through the PMPro AWeber addon.
Your fields must be created already in AWeber and also stored as user meta for the users.
Add this code to your active theme's functions.php or a custom plugin.
*/
function my_pmpro_aweber_custom_fields($fields, $user)
{
$fields['custom_field_name'] = get_user_meta($user->ID, "custom_field_name", true);
return $fields;
}
@strangerstudios
strangerstudios / show_login_register_links_on_member_pages.php
Created Jan 6, 2016
Show a login/register link at the bottom of any post that uses PMPro's membership shortcode.
View show_login_register_links_on_member_pages.php
View pmpro-disable-all-emails.php
<?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 / pmpro_cancel_on_next_payments_date.php
Last active Apr 30, 2020
Change PMPro membership cancellation to set expiration date for next payment instead of cancelling immediately.
View pmpro_cancel_on_next_payments_date.php
/*
Change cancellation to set expiration date for next payment instead of cancelling immediately.
Assumes orders are generated for each payment (i.e. your webhooks/etc are setup correctly).
Since 2015-09-21 and PMPro v1.8.5.6 contains code to look up next payment dates via Stripe and PayPal Express APIs.
*/
//before cancelling, save the next_payment_timestamp to a global for later use. (Requires PMPro 1.8.5.6 or higher.)
function my_pmpro_before_change_membership_level($level_id, $user_id) {
//are we on the cancel page?
You can’t perform that action at this time.