Skip to content

Instantly share code, notes, and snippets.

strangerstudios / my_pmpro_custom_tax_example.php
Last active May 16, 2023 10:41
Custom tax structure for Paid Memberships Pro where level 1 has no tax and all other levels have 7.25% tax if billing state is CA.
View my_pmpro_custom_tax_example.php
Custom Tax Example.
- Requires PMPro 1.3.13 or higher.
- Leave the tax fields blank in the payment settings.
- Level 1 has no tax.
- Other levels have 7.25% tax for CA customers only.
- We update the price description to include the tax amount.
function my_pmpro_tax($tax, $values, $order)
strangerstudios / heartbeat-api-demo.php
Last active April 13, 2023 16:49
Minimal example demonstrating the WordPress Heartbeat API being added in WP version 3.6.
View heartbeat-api-demo.php
Plugin Name: Heartbeat API Demo
Plugin URI:
Description: Minimal example demonstrating the WordPress Heartbeat API being added in WP version 3.6.
Version: .1
Author: strangerstudios
If logged in as a user and viewing the frontend of your website,
every 15 seconds you should see the following in your Javascript console:
strangerstudios / my_pmpro_default_registration_level.php
Created May 13, 2014 16:05
View my_pmpro_default_registration_level.php
* When registering, add the member to a specific membership level
* @param integer $user_id
//Disables the pmpro redirect to levels page when user tries to register
add_filter("pmpro_login_redirect", "__return_false");
function my_pmpro_default_registration_level($user_id) {
View my_pmpro_member_links
strangerstudios / assign_pmpro_level_to_role.php
Created February 18, 2014 16:11
Assign a Paid Memberships Pro level based on user role when user roles are updated.
View assign_pmpro_level_to_role.php
function assign_pmpro_level_to_role($user_id, $role, $old_roles)
//we found a role related to pmpro level
if($role == "pmpro_level_1")
pmpro_changeMembershipLevel(1, $user_id);
elseif($role == "administrator")
pmpro_changeMembershipLevel(2, $user_id); //setup level 2 as an all access role or just give them level 1
strangerstudios / my_gettext_pmpro_mailchimp.php
Created August 29, 2014 16:32
Change wording in PMPro MailChimp Opt In Box
View my_gettext_pmpro_mailchimp.php
Change wording in PMPro MailChimp Opt In Box
Add this code to your active theme's functions.php or a custom plugin.
Change the $translated_text = lines to the text you want.
function my_gettext_pmpro_mailchimp($translated_text, $text, $domain)
if($domain == "pmpro" && $text == "Join one or more of our mailing lists.")
$translated_text = "Join one or more of our newsletters.";
elseif($domain == "pmpro" && $text == "Join our mailing list.")
strangerstudios / pmpro_clear_all_data_init.php
Last active January 18, 2023 07:50
Clear out all PMPro member and report data. (Back up your database first. For development use only. Use at your own risk!!!)
View pmpro_clear_all_data_init.php
Clear out all PMPro member and report data. (Back up your database first. Use at your own risk!!!)
This will delete all orders, members/level data, and reporting data.
Your levels, discount codes, and settings will remain in place.
All users will remain users (without memberships).
All subscriptions at the gateway will remain active.
To Use:
* Copy this code into your active theme's functions.php or a custom WP plugin.
* Navigate to /wp-admin/?pmprocleardata=1 when logged in as an admin.
strangerstudios / coming_soon.php
Created August 13, 2014 15:02
Various options for redirecting to a "Coming Soon" page with WordPress.
View coming_soon.php
1. Create a page called "Coming Soon" with the slug "coming-soon".
If you use something different, be sure to update the code below.
2. Copy just one of the blocks of code below to a custom plugin or your active theme's functions.php.
//redirect non-users to the coming soon page
function coming_soon_redirect()
strangerstudios / wp_footer_asterisk_fix.php
Last active January 11, 2023 23:07
Move required asterisks into the field labels of the Paid Memberships Pro checkout page.
View wp_footer_asterisk_fix.php
strangerstudios / pmpro_after_checkout_gift_level_set_expiration.php
Created July 1, 2014 14:48
Code to get PMPro Gift Levels and PMPro Set Expiration Dates to play together nicely.
View pmpro_after_checkout_gift_level_set_expiration.php
Define Gift Levels
function init_gift_level()
//define the levels
global $pmprogl_gift_levels;
$pmprogl_gift_levels = array(
4 => array( // "Purchase Gift" level ID
'level_id' => 1, // Membership Level ID of the gift membership level.