Skip to content

Instantly share code, notes, and snippets.

View kimcoleman's full-sized avatar

Kim Coleman kimcoleman

View GitHub Profile
@kimcoleman
kimcoleman / args_add_ons.php
Last active August 3, 2018 19:32
Args for Add Ons CPT
<?php
$args = array(
'labels' => $labels,
'description' => __( 'Paid Memberships Pro Add Ons', 'pmpro' ),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'add-ons' ),
@kimcoleman
kimcoleman / memberlite_modify_tml_widget.php
Created August 4, 2018 15:46
Modify the Theme My Login widget title and user links displayed when using the Memberlite theme (https://memberlitetheme.com).
<?php //Do not copy this PHP tag into your code.
/**
* Modify the Theme My Login widget title and user links displayed when using the Memberlite theme
* https://memberlitetheme.com
*
* This code recipe changes the widget's title to "Welcome, Display_Name" for logged in users.
*
* It also removes the default user links included in the widget and replaces it with
* the same links as your "Members" menu as assigned under Appearance > Menus when using Memberlite.
* under Memberships > Pages.
@kimcoleman
kimcoleman / memberlite-customizations.php
Created August 4, 2018 16:12
A blank plugin file for customizations to your Memberlite setup.
<?php
/*
Plugin Name: Memberlite Customizations
Plugin URI: https://memberlitetheme.com/create-a-plugin-for-customizations-to-your-memberlite-site/
Description: A plugin for customizations to your Memberlite setup.
Version: .1
Author: Stranger Studios
Author URI: https://www.strangerstudios.com
*/
@kimcoleman
kimcoleman / custom_pmpro_upcoming_recurring_payment_reminder.php
Last active December 16, 2020 17:31
Filter to modify the days prior to renewal that the Recurring Payment Email Reminders Add On sends members the membership_recurring email notifcation.
<?php
/**
* Filter to modify the days prior to renewal that the Recurring Payment Email Reminders Add On
* sends members the membership_recurring email notifcation.
*
* Add this code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function custom_pmpro_upcoming_recurring_payment_reminder( $rec_array ) {
$rec_array = array( 30 => 'membership_recurring', );
return $rec_array;
@kimcoleman
kimcoleman / pmpro_customizations_lisagrayarea.php
Created August 15, 2018 11:54
Code to collect additional donations to specific categories at checkout, display fields on admin profile view, Members List, and include in Members List CSV Export.
<?php
/*
* Code to collect additional donations to specific categories or causes using the
* Register Helper Add On for Paid Memberships Pro.
* This is a different/independent approach from using the Donations Add On for Paid Memberships Pro.
*/
function my_pmpro_checkout_level($level)
{
$donation = 0;
@kimcoleman
kimcoleman / my_memberlite_manual_excerpt_more.php
Created August 15, 2018 16:54
Add a (more...) link when you specify a manual except to a post using the "Excerpt" post meta box.
<?php
/**
* Add an excerpt more string to manually created excerpts.
*/
function my_memberlite_manual_excerpt_more( $excerpt ) {
$excerpt_more = '';
if ( has_excerpt() ) {
$excerpt_more = ' <a href="' . get_permalink( ) . '" rel="nofollow">(more...)</a></a>';
}
return $excerpt . $excerpt_more;
<?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_after_expire_membership_level_default_level.php
Last active August 22, 2018 12:37
Place a PMPro member in another level when they expire and set an expiration date.
<?php
/**
* When users expire (and the system changes them to membership level 0) we give them another downgraded level.
*/
function my_pmpro_membership_post_membership_expiry( $user_id, $level_id ) {
// Set this to the id of the level you want to give members when they cancel.
$downgrade_level_1 = array(
'user_id' => $user_id,
'membership_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' );