Skip to content

Instantly share code, notes, and snippets.

View eighty20results's full-sized avatar

Thomas Sjølshagen eighty20results

View GitHub Profile
@eighty20results
eighty20results / pmpro-start-of-month-payments.php
Created August 27, 2016 17:50
Prorate the inital payment & set the start date for the recurring payments to the 1st of the month
<?php
/*
Plugin Name: Prorated initial membership payment
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Will prorate the membership payment from today until the 1st of the next month.
Version: .1
Author: Thomas Sjolshagen @ Stranger Studios <thomas@eighty20results.com>
Author URI: http://www.eighty20results.com/thomas-sjolshagen
*/
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 April 16, 2018 19:37
Preserve startdate on membership level change
/*
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 April 16, 2018 19:34
Preserve initial startdate for member regardless of how the membership level is updated.
<?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 April 16, 2018 19:29
Cancel the membership at the end of the month, not immediately.
/*
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 / pmpro_next_year_expiration.php
Created March 15, 2016 14:53
For new sign-ups, expire the membership level on Dec 31st, the year after they signed up.
<?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 March 16, 2016 18:27
Allow user to define a custom expiration interval (defined in constant)
<?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 13:37
Create Register Helper fields & sync them with the corresponding BuddyPress fields
<?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
*/
@eighty20results
eighty20results / pmpro-extra-fields.php
Created January 23, 2016 17:34
Add Extra fields for PMPro
<?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 September 3, 2016 14:11
Limit access to BuddyPress components for users without a valid Paid Memberships Pro membership level
<?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
*/