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 / gist:c3ec63f9b1ea1f91a10bae6796f27e2f
Created March 28, 2019 18:25 — forked from strangerstudios/gist:4081449
Change Paid Memberships Pro Email Subjects
/*
Change email subjects.
The function checks $email->template and updates the subject as needed.
The email template name will be equivalent to the filenames in the /email/ folder of the PMPro plugin.
*/
function my_pmpro_email_subject($subject, $email)
{
//only checkout emails
@LMNTL
LMNTL / pmpro-adjust-email-subject-to-level-checkout.php
Last active March 28, 2019 19:17 — forked from pbrocks/pmpro-adjust-email-content-to-level-checkout.php
This gist changes the subject line of the checkout email based on the member's level. - based on https://gist.github.com/pbrocks/abe099df6a462cb2353240af63a53959
<?php
/**
* Change subject line of Checkout email based on membership level.
*
* @param string $subject The email's subject is a string of text that you can adjust here as you see fit or pull from another custom function.
* @param object $email This is the php object from which we extracting the appropriate level and to which we'll add the new email content.
* @return string Whichever condition applies in the function below will determine what string is supplied to the email object. If none of the conditions are met, the return string will be the original message subject.
*/
function pmpro_adjust_email_subject_to_level_checkout( $subject, $email ) {
@LMNTL
LMNTL / pmpro_after_change_membership_level_default_level.php
Last active April 23, 2019 21:02 — forked from strangerstudios/pmpro_after_change_membership_level_default_level.php
Place a PMPro member in another level with a 30 day expiration date when they cancel/expire unless they are cancelling from that level.
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;
//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;
function my_custom_memberslist_order($sqlQuery)
{
echo "<a href=".admin_url('admin.php?page=pmpro-memberslist&enddate_sort=asc').">Sort by Enddate ASC</a><br>".
"<a href=".admin_url('admin.php?page=pmpro-memberslist&enddate_sort=desc').">Sort by Enddate DESC</a>";
if(isset($_REQUEST['enddate_sort']) && ($_REQUEST['enddate_sort'] == 'asc' || $_REQUEST['enddate_sort'] == 'desc'))
{
$sort_order = $_REQUEST['enddate_sort'];
global $wpdb;
@LMNTL
LMNTL / pmpro-add-role-custom-roles.php
Last active May 20, 2019 18:44 — forked from strangerstudios/pmpro-change-role-custom-roles.php
Add a custom role for new PMPro members at checkout. Add this code to your active theme's functions.php or a custom plugin. - based on https://gist.github.com/strangerstudios/7280471
<?php
/*
This code assumes you already have a 'myrole' custom role created.
Members signing up get the 'myrole' role in addition to any other roles they already have.
Members cancelling are given the subscriber role.
Admin users are ignored.
Usable with or without the PMPro Roles Add On.
*/
function my_pmpro_after_change_membership_level($level_id, $user_id)
{
@LMNTL
LMNTL / my_pmproec_pmpro_after_change_membership_level.php
Created May 22, 2019 18:35 — forked from messica/my_pmproec_pmpro_after_change_membership_level.php
Make PMPro MailChimp compatible with PMPro Email Confirmation
<?php
/**
* Make PMPro MailChimp compatible with PMPro Email Confirmation
*/
// Don't subscribe to MailChimp if user is not validated.
function my_pmproec_pmpro_after_change_membership_level($level_id, $user_id) {
if( function_exists('pmproec_isEmailConfirmationLevel') && pmproec_isEmailConfirmationLevel($level_id) ) {
$validation_key = get_user_meta($user_id, "pmpro_email_confirmation_key", true);
/*
Restrict membership access based on parent category
*/
function category_restrictions($hasaccess, $mypost, $myuser, $post_membership_levels)
{
global $post, $current_user;
$categories = wp_get_post_categories($mypost->ID);
$restrict = false;
@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),
@LMNTL
LMNTL / pay-by-check-no-access.php
Last active July 26, 2019 20:52 — forked from andrewlimaza/pay-by-check-no-access.php
Force users with pending orders from Pay By Check Add On and PMPro to not have access to any member content.
<?php
/**
* This checks to see if the user has a 'pending' check order and will deny access whever member content is called.
* Add this code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function pmpro_deny_if_user_is_pending( $hasaccess, $post, $user, $levels ) {
$order = new MemberOrder();
$order->getLastMemberOrder( $user->ID, array( 'pending', '', 'check' ) );
@LMNTL
LMNTL / pmpro-file-upload-avatar-register-helper.php
Last active October 11, 2019 13:10 — forked from greathmaster/pmpro-file-upload-avatar-register-helper.php
Upload avatar image from the checkout using the PMPro Register Helper Add On. No other plugins required.
/*
* Add WP User Avatar from Register Helper field during checkout.
*/
function my_updated_user_meta($meta_id, $user_id, $meta_key, $meta_value) {
// Change user_avatar to your Register Helper file upload name.
if( 'user_avatar' == $meta_key) {
$filename = $meta_value['fullpath'];
$filetype = wp_check_filetype( basename( $filename ), null );
$wp_upload_dir = wp_upload_dir();
$attachment = array(