Skip to content

Instantly share code, notes, and snippets.

@andrewlimaza
andrewlimaza / remove_billing_example.php
Created June 12, 2017 07:48
Remove 'Billing' from 'Billing Address' title in Paid Memberships Pro.
<?php
/**
* Copy the function below into your PMPro Customizations plugin - http://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* This function uses the gettext filter which will change all text occurences of Billing Address to Address in Paid Memberships Pro.
*/
function change_text_billing_pmpro( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Billing Address' :
$translated_text = __( 'Address', 'paid-memberships-pro' );
break;
@strangerstudios
strangerstudios / my_pmpro_disable_member_emails.php
Created March 10, 2017 19:34
Disable member emails for specific levels.
function my_pmpro_disable_member_emails($recipient, $email)
{
$user = get_user_by('login', $email->data['user_login']);
$level = pmpro_getMembershipLevelForUser($user->ID);
$disabled_levels = array(1,2,3); //update this to include ids of all levels you want to disable emails for
if(!empty($level) && !empty($level->id) && in_array($level->id, $disabled_levels))
$recipient = NULL;
@strangerstudios
strangerstudios / pmpro_hide_level_from_levels_page.php
Last active April 8, 2021 18:21 — forked from greathmaster/pmpro-restrict-visibility-of-levels-on-levels-page.php
Limits the visibility of a level on the Levels page. Unlike setting "Allow Signups" members can access the checkout page to renew if needed.
<?php
//Save the pmpro_show_level_ID field
function pmpro_hide_level_from_levels_page_save( $level_id ) {
if( $level_id <= 0 ) {
return;
}
$limit = $_REQUEST['pmpro_show_level'];
update_option( 'pmpro_show_level_'.$level_id, $limit );
}
add_action( 'pmpro_save_membership_level','pmpro_hide_level_from_levels_page_save' );
@strangerstudios
strangerstudios / $pmpro_non_renewal_levels.php
Created March 28, 2016 16:22
Don't allow early renewals for certain levels with Paid Memberships Pro.
/*
Don't allow early renewals for certain levels.
Change the level IDs in the $pmpro_non_renewal_levels global array, then
add this code to your active theme's functions.php or a custom plugins.
*/
//define levels in global
global $pmpro_non_renewal_levels;
$pmpro_non_renewal_levels = array(1,2,3); //change this to the level IDs of the levels you don't want users to renew for
@strangerstudios
strangerstudios / pmpro_is_page.php
Last active January 22, 2024 17:08
Tests to check if you are on certain PMPro pages.
<?php
global $pmpro_pages, $pmpro_level;
if(is_page($pmpro_pages['levels'])) {
//on the pricing/levels page
}
if(is_page($pmpro_pages['checkout'])) {
//on the checkout page
}
@eighty20results
eighty20results / pmpro_cancel_on_next_payments_date.php
Last active July 17, 2019 20:22 — forked from strangerstudios/pmpro_cancel_on_next_payments_date.php
Change PMPro membership cancellation to set expiration date to be the end of the payment period, instead of cancelling immediately (except when payment gateway is causing cancellation)
<?php
/*
Change cancellation to set expiration date et expiration date to be the end of the current month, instead of cancelling immediately.
Assumes orders are generated for each payment (i.e. your webhooks/etc are setup correctly).
*/
function e20r_stripe_delete_action( $user_id ) {
@strangerstudios
strangerstudios / my_template_redirect_upgrade.php
Created April 14, 2015 16:12
Redirect away from the checkout page if you don't have a required level with Paid Memberships Pro.
/*
Redirect away from the checkout page if you don't have a required level.
*/
function my_template_redirect_upgrade()
{
global $pmpro_pages, $pmpro_level;
if(empty($pmpro_pages))
return;
@developius
developius / README.md
Last active May 20, 2025 11:20
Setup SSH keys for use with GitHub/GitLab/BitBucket etc
@strangerstudios
strangerstudios / pmprobuddy_update_user_meta.php
Last active October 18, 2022 20:48
Sync WordPress user meta fields (e.g. those added by PMPro Register Helper) with BuddyPress profile fields.
/*
Sync PMPro fields to BuddyPress profile fields.
*/
function pmprobuddy_update_user_meta($meta_id, $object_id, $meta_key, $meta_value)
{
//make sure buddypress is loaded
do_action('bp_init');
//array of user meta to mirror
$um = array(
@strangerstudios
strangerstudios / pmpro_after_change_membership_level_default_level.php
Last active April 7, 2022 20:32
Place a PMPro member in another level when they cancel... unless they are cancelling from that level.
/*
When users cancel (are changed to membership level 0) we give them another "cancelled" level.
Can be used to downgrade someone to a free level when they cancel.
Will allow members to the "cancel level" to cancel from that though.
*/
function my_pmpro_after_change_membership_level_default_level($level_id, $user_id)
{
//set this to the id of the level you want to give members when they cancel
$cancel_level_id = 1;