Skip to content

Instantly share code, notes, and snippets.

View scottsousa's full-sized avatar

Scott Sousa scottsousa

View GitHub Profile
@scottsousa
scottsousa / gist:8847073
Created February 6, 2014 16:02
Paid Memberships Pro - This function will output the number of days left in a trial period for a user in the member links section on the account page.
/**
* This function will output the number of days left in a trial period for a user in the
* member links section on the account page.
*/
add_action( 'pmpro_member_links_top', 'my_pmpro_member_links_top' );
function my_pmpro_member_links_top() {
// Get current level details
$user_level = pmpro_getMembershipLevelForUser();
// Make sure we have a trial
@scottsousa
scottsousa / gist:8714946
Created January 30, 2014 18:10
Paid Memberships Pro - When checking out adjust the starting recurring payment date. Applies to new and existing users.
/**
* When checking out adjust the starting recurring payment date. Applies to new and existing users.
*
* $monthly_cutoff_day is the day of each month that the start date should be adjusted
* We're also checking to see if it's before March 15th, 2014 in this example.
*/
function my_pmpro_profile_start_date( $startdate, $order ) {
$monthly_cutoff_day = 16; // (e.g. March 16th) Adjust this value accordingly, this is the day of the month that the start date should be rolled over to the next month
$current_day = ( int ) date( 'd' ); // Get the current day of the month
@scottsousa
scottsousa / gist:8580472
Created January 23, 2014 15:26
Paid Memberships Pro - Prevent users from downgrading levels.
/**
* Prevent users from downgrading levels.
*/
add_filter( 'pmpro_checkout_level', 'my_pmpro_checkout_level' );
function my_pmpro_checkout_level( $level ) {
// Check to see if the current user is downgrading (Gold to Silver or Gold to Free)
if( pmpro_hasMembershipLevel( 3 ) && ( $level->id == 2 || $level->id == 1 ) ) {
// Re-direct them to page explaining why they cannot downgrade
wp_redirect( home_url( '/gold-downgrade-message' ) );
exit;
@scottsousa
scottsousa / gist:8542877
Created January 21, 2014 16:04
Paid Memberships Pro - Add discount codes to Member list
/**
* Hook into Members List header
*/
add_action( 'pmpro_memberslist_extra_cols_header', 'my_pmpro_memberslist_extra_cols_header' );
function my_pmpro_memberslist_extra_cols_header() {
echo '<th>Discount Code</th>';
}
/**
* Hook into Members List body to show discount code
@scottsousa
scottsousa / gist:8357002
Created January 10, 2014 16:00
PMPro - Nicer level costs for trial periods
/*
Nicer level costs for levels that have trial periods.
*/
function nicer_pmpro_level_cost_text($text, $level)
{
global $pmpro_currency_symbol;
if(pmpro_isLevelFree($level))
$text = "Membership is free.";
// Levels that have a trial
@scottsousa
scottsousa / gist:6700307
Last active May 22, 2018 16:07
Paid Memberships Pro - Add custom confirmation message for a level to checkout e-mail templates without creating a custom template. See comments in code for more details.
/**
* This function allows a custom confirmation message to be added to a checkout e-mail template. This will allow you to add
* your custom confirmation message to an e-mail template, without creating your own custom template in your theme.
*
* We're checking for the "checkout_" prefix on the e-mail template name and if we have current user data.
* We're then getting the custom confirmation level based on the current user data.
* We replace the 'is now active.</p>' portion of the body to append the confirmation message.
*/
add_filter( 'pmpro_email_body', 'my_pmpro_email_body', 10, 2 );
function my_pmpro_email_body( $body, $email ) {
@scottsousa
scottsousa / gist:6156641
Created August 5, 2013 15:07
Force a user to use strong passwords in Paid Memberships Pro. This plugin checks for length, matching/containing username, lowercase/uppercase, numbers, and special characters
<?php
/*
Plugin Name: PMPro Strong Passwords
Version: 0.1
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Force users to submit strong passwords.
Version: .1
Author: Scott Sousa
Author URI: http://slocumstudio.com