Skip to content

Instantly share code, notes, and snippets.

View LMNTL's full-sized avatar

Jessica Thomas LMNTL

  • Chicago, IL
View GitHub Profile
@LMNTL
LMNTL / pmprosm_sponsored_discount_code_reuse.php
Created July 16, 2019 20:53
Delete Sponsored Members discount code uses whenever a sponsored member is cancelled/expired
// Delete Sponsored Members discount code uses whenever a sponsored member is cancelled/expired
function my_pmprosm_sponsored_discount_code_reuse($level_id, $user_id) {
global $pmpro_next_payment_timestamp;
// if we see this global is set, other code is planning on giving them their level back
if( !empty($pmpro_next_payment_timestamp) )
return $level_id;
//make sure they're cancelling and they have a sponsored level
if( $level_id == 0 && pmprosm_isSponsoredLevel(pmpro_getMembershipLevelForUser($user_id)->ID) )
{
//get sponsor for user
@LMNTL
LMNTL / my_pmpro_show_renew_link_hidden_level.php
Last active July 11, 2019 01:47
Show "Renew" link on the Membership Account page for levels that are have "Disable new signups?" checked
@LMNTL
LMNTL / my_pmprobc_dont_show_pending_level.php
Created July 4, 2019 18:24
If a member has a pending check order for a level, don't show that level on the Levels page
/** If a member has a pending check order for a level, don't show that level on the Levels page
* Compatible with the Advanced Shortcode Add On.
* Requires PMPro and Pay By Check to be installed and configured
*/
function my_pmprobc_dont_show_pending_level( $level_array ){
// get the last order for the current user
$last_order = new MemberOrder();
$last_order->getLastMemberOrder(NULL, NULL);
@LMNTL
LMNTL / my_pmproec_change_confirmation_text
Created July 3, 2019 19:15
Change the text for the confirmation link in the PMPro Email Confirmation Add On welcome email
// change the text for the confirmation link in the PMPro Email Confirmation Add On welcome email
function my_pmproec_change_confirmation_text($body)
{
//change this line to modify the confirmation text
$new_confirmation_text = "Click this link to activate your membership:";
$old_confirmation_text = "IMPORTANT! You must follow this link to confirm your email address before your membership is fully activated:";
$body = str_replace( $old_confirmation_text, $new_confirmation_text, $body );
return $body;
@LMNTL
LMNTL / my_pmprobc_no_renewal_before_approval.php
Last active July 4, 2019 18:25
Don't show renewal link on the Levels page for Pay by Check users with pending orders
/** Don't show renewal link on the Levels page for Pay by Check users with pending orders
* Not compatible with the Advanced Levels Page Shortcode Add On; use this gist instead: https://gist.github.com/LMNTL/c8549aa27d259a21a2841560f4a2e1c5
* requires Pay by Check Add On to be installed and configured
*/
function my_pmprobc_no_renewal_before_approval( $show, $level ){
// get the last order for the current user
$last_order = new MemberOrder();
$last_order->getLastMemberOrder(NULL, NULL);
@LMNTL
LMNTL / my_pmpro_dlm_has_download_access.php
Last active June 19, 2019 23:23
Require PMPro membership for all Download Monitor downloads. Requires Paid Memberships Pro and Download Monitor to be installed and configured.
/*
Require PMPro membership for all Download Monitor downloads.
Requires Paid Memberships Pro and Download Monitor to be installed and configured
NOTE: this will work with or without the Download Monitor Integration Add On for PMPro.
*/
function my_pmpro_dlm_has_download_access( $continue ) {
/* you can change this line to restrict download to only specific levels
https://www.paidmembershipspro.com/documentation/content-controls/require-membership-function/ */
@LMNTL
LMNTL / my_pmprorh_remove_box_for_members.php
Created June 19, 2019 20:30
Don't include specific Register Helper checkout box/boxes on the checkout page for members
// don't include specific Register Helper checkout box/boxes on the checkout page for members
function my_pmprorh_remove_box_for_members(){
if( pmpro_hasMembershipLevel() )
{
global $pmprorh_checkout_boxes;
// change this line to include the name of the checkout box(es) to remove
$boxes_to_remove = array("more_fields");
$new_boxes = [];
@LMNTL
LMNTL / pmpro_levels_array_cancelled.php
Created June 18, 2019 19:09
Show the last membership level had, even if hidden, for members with a "cancelled" role on levels page
function my_pmpro_levels_array_cancelled($levels)
{
$current_user = wp_get_current_user();
$user_meta = get_userdata($current_user->ID);
if( in_array( "cancelled", $user_meta->roles ) )
{
$order = new MemberOrder();
$order->getLastMemberOrder($current_user->ID, array("cancelled","expired","error"));
if( empty( $order->id ) )
return $levels;
@LMNTL
LMNTL / pmpro_rh_restrict_users.php
Last active March 11, 2022 17:59
Restrict members from accessing members-only content using a checkbox in the profile. Requires PMPro and Register Helper Add On.
<?php
/*
Restrict members from accessing members-only content using a checkbox in the profile.
The button will only show when logged in as an admin.
Requires PMPro and Register Helper Add On to be installed, activated, and configured.
*/
function my_pmprorh_init_restrict()
{
//don't break if Register Helper is not loaded
@LMNTL
LMNTL / pmpro_reports_changes.php
Created June 6, 2019 21:19 — forked from strangerstudios/pmpro_reports_changes.php
A report to show membership level changes (upgrades or downgrades) from initial level to current level.
<?php
/*
Changes Report for Paid Memberships Pro
Title: pmpro_reports_changes
Slug: pmpro_reports_changes
*/
//update this array for your desired reports. the format is: "report name" => array( initial_level_id, current_level_id ),
global $pmpro_reports_level_changes;
$pmpro_reports_level_changes = array(
"Members upgrading from Level 1 to 2" => array( 1, 2),