Skip to content

Instantly share code, notes, and snippets.

View kimcoleman's full-sized avatar

Kim Coleman kimcoleman

View GitHub Profile
@kimcoleman
kimcoleman / pmprodon_pmpro_donation_recurring.php
Last active January 22, 2022 12:03 — forked from andrewlimaza/pmpro-recurring-donations.php
Adds recurring donation functionality to the Donations Add On for Paid Memberships Pro: https://www.paidmembershipspro.com/add-ons/donations-add-on/
<?php
/*
* This gist adds recurring functionality to the Donations Add On for Paid Memberships Pro.
* It adds the user-entered 'donation amount' to their recurring billing amount.
*/
//add donation amount to recurring payment amount
function pmprodon_pmpro_donation_recurring( $level ) {
if( isset( $_REQUEST['donation'] ) ) {
$donation = preg_replace( '[^0-9\.]', '', $_REQUEST['donation'] );
@kimcoleman
kimcoleman / my_pmpro_payment_method.css
Last active October 12, 2023 19:48 — forked from strangerstudios/my_pmpro_payment_method.css
Adds credit card logos and a PayPal logo to the "Select Payment Method" box on membership checkout.
/* CSS Document */
#pmpro_payment_method span a {
background-position: left bottom;
background-size: contain;
background-repeat: no-repeat;
display: inline-block;
margin-left: 1%;
max-width: 300px;
padding-bottom: 60px;
text-align: left;
@kimcoleman
kimcoleman / pmpro-expire-soon-banner.php
Last active July 17, 2023 13:22 — forked from travislima/pmpro-expire-soon-banner.php
Create a banner that will display a message to soon to be expiring members
<?php
/**
* This code will display a renewal reminder notification banner at the top of your website for members whose membership
* level will expire within 7 days of the date they visit your site.
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* Note: When adding to your Customizations Plugin, be careful not to include the opening php tag on line 1 above.
*/
function pmpro_show_banner_renewal_message() {
global $pmpro_pages;
@kimcoleman
kimcoleman / memberlite-banner-expiration-notification.php
Last active July 17, 2023 13:20 — forked from travislima/memberlite-banner-expiration-notification.php
Display a banner that notifies users about their upcoming expiration - Memberlite method.
<?php
/**
* This code will display a renewal reminder notification banner at the top of your website for members whose membership
* level will expire within 7 days of the date they visit your site.
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* Note: When adding to your Customizations Plugin, be careful not to include the opening php tag on line 1 above.
*/
function memberlite_show_banner_renewal_message(){
global $pmpro_pages;
@kimcoleman
kimcoleman / pmpro_level_groups_pmpro_checkout_boxes.php
Last active August 16, 2018 17:43 — forked from strangerstudios/pmpro_level_groups.php
Example of how to show different payment option levels at checkout with Paid Memberships Pro.
<?php //Do not copy this PHP tag into your code.
/**
* Define groups of levels and allow members to select from both levels at checkout.
* Useful for offering multiple pricing structures for membership (i.e. Monthly, Annually)
*
* Add this code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
// Define the groups of levels. array(1,2) means that levels 1 and 2 are in a group and options will be shown for both levels at checkout for those levels.
global $pmpro_level_groups;
@kimcoleman
kimcoleman / pmpro_after_change_membership_level_default_level.php
Last active August 22, 2018 10:57 — forked from strangerstudios/pmpro_after_change_membership_level_default_level.php
Place a PMPro member in another level when they cancel... unless they are cancelling from that level.
<?php
/**
* 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;
@kimcoleman
kimcoleman / my_pmpro_widget_display_callback.php
Created August 22, 2018 14:55 — forked from strangerstudios/my_pmpro_widget_display_callback.php
Hide widgets by sidebar ID on members only content when the user does not have access.
<?php
/**
* Hide widgets by widget area ID for protected members only contnet.
* Update the $hide_sidebars_array with the array of sidebar IDs you want to filter.
* Add this code to your active theme's functions.php or a custom plugin.
*/
function my_pmpro_widget_display_callback( $instance, $widget, $args ) {
// Set an array of widget areas by ID to filter.
$hide_sidebars_array = array( 'sidebar-1', 'sidebar-2' );
@kimcoleman
kimcoleman / donteatthat_pmpro_checkout_level.php
Last active October 19, 2018 10:51 — forked from strangerstudios/my_pmpro_checkout_level.php
PMPro Register Helper Customizations for donteatthat Thread
<?php
/**
* Custom Register Helper fields for donteatthat thread on price-adjusting fields.
*/
function donteatthat_pmprorh_init() {
// Don't break if Register Helper is not loaded.
if ( ! function_exists( 'pmprorh_add_registration_field' ) ) {
return false;
}
@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' ) );
<?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.