Skip to content

Instantly share code, notes, and snippets.

View kimcoleman's full-sized avatar

Kim Coleman kimcoleman

View GitHub Profile
@kimcoleman
kimcoleman / pmpro-sitewide-sale-ocean-template-demo.php
Created November 1, 2018 18:12
Demo content for the "Ocean" template example of Sitewide Sale Add On for Paid Memberships Pro
<?php
/*
* This is demo content for the Sitewide Sale Add On for Paid Memberships Pro.
* You can view a live preview of this content in the "Ocean" Sale Template here:
* https://demo.memberlitetheme.com/membership/sitewide-sales/sample-sale-3/
*
* Remove this comment and place the content below into the "Sale Content" field of your Sitewide Sale.
*/
?>
<div class="text-center">
@kimcoleman
kimcoleman / pmpro-sitewide-sale-photo-template-demo.php
Created November 1, 2018 18:15
Demo content for the "Photo" template example of Sitewide Sale Add On for Paid Memberships Pro
<?php
/*
* This is demo content for the Sitewide Sale Add On for Paid Memberships Pro.
* You can view a live preview of this content in the "Photo" Sale Template here:
* https://demo.memberlitetheme.com/membership/sitewide-sales/sample-sale-4/
*
* Remove this comment and place the content below into the "Sale Content" field of your Sitewide Sale.
*/
?>
<h1>Quit Clowning Around</h1>
@kimcoleman
kimcoleman / pmpro-sitewide-sale-scroll-template-demo.php
Created November 1, 2018 18:24
Demo content for the "Scroll" template example of Sitewide Sale Add On for Paid Memberships Pro
<?php
/*
* This is demo content for the Sitewide Sale Add On for Paid Memberships Pro.
* You can view a live preview of this content in the "Scroll" Sale Template here:
* https://demo.memberlitetheme.com/membership/sitewide-sales/sample-sale-5/
*
* Remove this comment and place the content below into the "Sale Content" field of your Sitewide Sale.
*/
?>
<div class="sws-banner">
@kimcoleman
kimcoleman / add_custom_pmpro_sws_landing_page_templates.php
Last active November 17, 2020 23:18
Adds a "Black Friday" template name to the array of available templates for Sitewide Sales Add On for Paid Memberships Pro.
<?php
/*
* Filters the array of available templates for Sitewide Sales Add On for Paid Memberships Pro.
*
* @param array $templates The default list of available templates.
*/
function add_custom_pmpro_sws_landing_page_templates( $templates ) {
$templates['black-friday'] = 'Black Friday'; // This is how you add a new template to the array.
//unset( $templates['neon'] ); // This is how you unset an included template from the array.
return $templates;
@kimcoleman
kimcoleman / maybe_add_choose_level_section.php
Created November 5, 2018 14:51
Hide the "Membership Level" description and pricing box at Membership Checkout and replace with our own box with radio-selection for multiple level display.
<?php
/**
* Hide the PMPro pricing box at checkout and replace with our own.
*
* Requires Paid Memberships Pro v1.9.5.6+ and the Sitewide Sales Add On v1.0+
*
* Add this code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function maybe_add_choose_level_section( $include_pricing_fields ) {
global $wpdb, $pmpro_level;
@kimcoleman
kimcoleman / pmpro_sitewide_sales_radio_select.php
Last active November 17, 2020 23:16
Add a radio box to the Sitewide Sale Landing Page that dynamically pulls in that sale's discount code and applicable levels.
<?php
/*
* Add a radio box to the Sitewide Sale Landing Page that dynamically pulls in that sale's discount code and
* draws a radio selection for each level the code applies to.
* Shows the modify level cost text based on the applied discount code for each level.
*/
/**
* We need to set $_REQUEST['level'] early on our
* sitewide sales pages to support other customizations.
@kimcoleman
kimcoleman / pmpro_checkout_level.php
Last active November 13, 2018 11:53 — forked from strangerstudios/pmpro_checkout_level.php
Discount a Paid Memberships Pro level half way through the year.
<?php
/*
* Add this code into a custom plugin. Combine this with the pmpro-set-expiration-date and/or pmpro-subscription-delay plugins
* to have memberships expire/renew on the same date, e.g. Y2-01-01 to expire/renew on Jan 1 next year.
*
* You can update the logic to check for different months or adjust the price in a different way. The code below divides the
* initial payment by 2 July 1 through Dec 31.
*/
function pmpro_checkout_level_half_off_mid_year( $level ) {
$month = date( 'n', current_time( 'timestamp' ) );
@kimcoleman
kimcoleman / pmpro_after_change_membership_level_structure.php
Last active November 15, 2018 13:50
Custom cancellation for use sabbella
<?php
/**
* Custom downgrade on membership cancellation code for sabbella ticket.
*/
function sabbella_pmpro_after_change_membership_level_downgrades( $level_id, $user_id ) {
// if we see this global set, then another gist is planning to give the user their level back
global $pmpro_next_payment_timestamp;
if ( ! empty( $pmpro_next_payment_timestamp ) ) {
return;
@kimcoleman
kimcoleman / add_pmpro_checkout_body_class_sws.php
Last active November 15, 2018 18:49
Add the 'pmpro-checkout' body class to Sitewide Sales landing pages.
<?php
/*
* Add the 'pmpro-checkout' body class to Sitewide Sales landing pages.
*
*/
function add_pmpro_checkout_body_class_sws( $classes ) {
// See if any Sitewide Sale CPTs have this post ID set as the Landing Page.
$sitewide_sale_id = get_post_meta( get_queried_object_id(), 'pmpro_sws_sitewide_sale_id', true );
if ( ! empty( $sitewide_sale_id ) ) {
$classes[] = 'pmpro-checkout';
<?php
/**
* Gift Levels Example for thehawaiiherald.com
*/
global $pmprogl_gift_levels;
$pmprogl_gift_levels = array(
// Set level 2 as a "Purchase Gift" membership level to create a gift code for "Basic Online" membership for 1 year.
2 => array( // "Purchase Gift" level ID
'level_id' => 1, // Membership Level ID of the gift membership level.