Skip to content

Instantly share code, notes, and snippets.

Avatar

Thomas Sjolshagen eighty20results

View GitHub Profile
View Expire membership access on last billing date
add_action( "pmpro_after_change_membership_level", "e20r_cancel_at_end_of_period", 10, 2 );
add_filter( "pmpro_email_body", "e20r_email_body_for_cancel_msg", 10, 2 );
/**
* Change cancellation to set expiration date for next payment instead of cancelling immediately.
* Assumes monthly membership levels.
* Assumes orders are generated for each payment (i.e. your webhooks/etc are setup correctly).
*
* @param (int) $level_id -- The membership levelId we're changing
* @param (int) $user_id -- The member we're changing levels for.
@eighty20results
eighty20results / preserve-startdate-including-registration-date.php
Last active Apr 16, 2018
Preserve startdate on membership level change
View preserve-startdate-including-registration-date.php
/*
Keep members start dates at checkout, even if switching levels.
*/
function custom_pmpro_checkout_start_date($date, $user_id, $level)
{
global $wpdb;
// Comment this out if you want to use the users registration date (Warning: Registration date may not contain data...)
$sqlQuery = "SELECT UNIX_TIMESTAMP(startdate) FROM $wpdb->pmpro_memberships_users WHERE user_id = '" . esc_sql($user_id) . "' ORDER BY id LIMIT 1";
@eighty20results
eighty20results / pmpro_preserve_startdate.php
Last active Apr 16, 2018
Preserve initial startdate for member regardless of how the membership level is updated.
View pmpro_preserve_startdate.php
<?php
/*
Plugin Name: PMPro Preserve Startdate
Plugin URI: https://eighty20results.com/paid-memberships-pro/do-it-for-me/
Description: Customization to preserve initial membership signup (startdate) value.
Version: 1.0
Author: Thomas Sjolshagen @ Stranger Studios <thomas@eighty20results.com>
Author URI: https://eighty20results.com/thomas-sjolshagen/
*/
/*
@eighty20results
eighty20results / e20r-end-of-month-membership-cancellation.php
Last active Apr 16, 2018
Cancel the membership at the end of the month, not immediately.
View e20r-end-of-month-membership-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).
*/
//give users their level back with an expiration
function e20r_pmpro_after_change_ml($level_id, $user_id)
{
@eighty20results
eighty20results / gh-custom-cancel-page
Created Apr 14, 2018
Load custom cancellation page for certain membership levels
View gh-custom-cancel-page
<?php
/**
* Filter handler for `pmpro_pages_shortcode_cancel` (load custom cancellation page for certain membeship levels)
*
* @param string $content
*
* @return string
*/
function gc_custom_cancel_page( $content ) {
@eighty20results
eighty20results / pmpro_next_year_expiration.php
Created Mar 15, 2016
For new sign-ups, expire the membership level on Dec 31st, the year after they signed up.
View pmpro_next_year_expiration.php
<?php
/*
Plugin Name: PMPro Expire New Memberships Next Year
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Customization to expire new membership sign-ups on Jan 1 the year after, the year after this one.
Version: .1
Author: Thomas Sjolshagen @ Stranger Studios <thomas@eighty20results.com>
Author URI: https://eighty20results.com/thomas-sjolshagen/
*/
function pmpro_next_year_expiration($level)
@eighty20results
eighty20results / pmpro_custom_expiration_interval.php
Created Mar 16, 2016
Allow user to define a custom expiration interval (defined in constant)
View pmpro_custom_expiration_interval.php
<?php
/*
Plugin Name: PMPro Custom Renew Button interval
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Customization to let admin specify how early to show the renew button.
Version: .1
Author: Thomas Sjolshagen @ Stranger Studios <thomas@eighty20results.com>
Author URI: https://eighty20results.com/thomas-sjolshagen/
*/
@eighty20results
eighty20results / pmpro-customization.php
Created May 5, 2016
Create Register Helper fields & sync them with the corresponding BuddyPress fields
View pmpro-customization.php
<?php
/*
Plugin Name: PMPro Customizations
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Customizations for Paid Memberships Pro
Version: .2
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
*/
View pmpro-extra-fields.php
<?php
/*
Plugin Name: Register Helper - Extra fields
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Extra registration fields
Version: .1
Author: Thomas Sjolshagen - PMPro Support
Author URI: http://www.strangerstudios.com/
*/
function my_pmprorh_extra_fields_init()
@eighty20results
eighty20results / pmpro-buddypress-membership-protection.php
Created Sep 3, 2016
Limit access to BuddyPress components for users without a valid Paid Memberships Pro membership level
View pmpro-buddypress-membership-protection.php
<?php
/*
Plugin Name: PMPro/BuddyPress members only access
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Limit access to BuddyPress pages/components for non-members.
Version: .1
Author: Thomas Sjolshagen @ Stranger Studios <thomas@eighty20results.com>
Author URI: http://www.eighty20results.com/thomas-sjolshagen
*/
You can’t perform that action at this time.