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 / my_pmpro_email_headers_admin_emails.php
Last active January 28, 2022 02:49 — forked from strangerstudios/my_pmpro_email_headers_admin_emails.php
BCC an additional email on PMPro admin emails. Works with PMPro Approvals emails.
/*
Add bcc for PMPro admin emails
*/
function my_pmpro_email_headers_admin_emails($headers, $email)
{
$approval_admin = array( "admin_approved", "admin_denied", "admin_notification" );
//bcc emails already going to admin_email
if( strpos($email->template, "_admin") !== false || in_array($email->template, $approval_admin) )
{
@LMNTL
LMNTL / custom_stylesheet.css
Created September 4, 2019 17:18
don't require the "State" field at checkout and hide it
.pmpro_checkout-field-bstate {
display: none;
}
@LMNTL
LMNTL / pmpromh_modified_login_redirect.php
Last active September 4, 2019 22:17
preserve requested redirect with PMPro Member Homepages
// preserve requested redirect with PMPro Member Homepages
// forked from @greathmaster
function pmpromh_modified_login_redirect($redirect_to, $request, $user)
{
if(isset($request) && $redirect_to != admin_url())
return $request;
//check level
if(!empty($user) && !empty($user->ID) && function_exists('pmpro_getMembershipLevelForUser')) {
$level = pmpro_getMembershipLevelForUser($user->ID);
@LMNTL
LMNTL / my_pmpro_woocommerce_on_hold_keep_membership.php
Created August 23, 2019 00:02
don't cancel memberships when woocommerce orders go on hold
// don't cancel memberships when woocommerce orders go on hold
function my_pmpro_woocommerce_on_hold_keep_membership()
{
remove_action( 'woocommerce_subscription_status_on-hold', 'pmprowoo_cancelled_subscription', 10, 1 );
remove_action( 'woocommerce_subscription_status_on-hold_to_active', 'pmprowoo_activated_subscription', 10, 1 );
}
add_action('init', 'my_pmpro_woocommerce_on_hold_keep_membership');
@LMNTL
LMNTL / my_pmpro_before_change_membership_level_customization.php
Created August 13, 2019 20:18
Change cancellation to set expiration date for next payment instead of cancelling immediately. (updated 8/13/19)
/*
Change cancellation to set expiration date for next payment instead of cancelling immediately.
Assumes orders are generated for each payment (i.e. your webhooks/etc are setup correctly).
Since 2015-09-21 and PMPro v1.8.5.6 contains code to look up next payment dates via Stripe and PayPal Express APIs.
*** Updated 2018-11-16 to also check for calls from PayFlow Recurring Orders Add On
*/
//before cancelling, save the next_payment_timestamp to a global for later use. (Requires PMPro 1.8.5.6 or higher.)
function my_pmpro_before_change_membership_level_customization($level_id, $user_id) {
global $pmpro_pages, $wpdb, $pmpro_stripe_event, $pmpro_next_payment_timestamp, $cancelling;
// Is this being called from the PayFlow Recurring Orders Add On?
@LMNTL
LMNTL / my_pmproship_remove_email_filter.php
Created August 12, 2019 17:41
Remove shipping address from PMPro-generated emails when using Shipping Add On
// Remove shipping address from PMPro-generated emails when using Shipping Add On
function my_pmproship_remove_email_filter()
{
remove_filter( "pmpro_email_body", "pmproship_pmpro_email_body", 10, 2 );
}
add_action( "init", "my_pmproship_remove_email_filter");
@LMNTL
LMNTL / my_pmprowoo_on_hold_keep_startdate.php
Last active August 15, 2019 23:39
preserve start date when PMPro WooCommerce subscriptions go into "on hold" status
function my_pmprowoo_active_preserve_startdate( $level_id, $user_id )
{
global $wpdb;
if( $level_id != 0 && did_action( "woocommerce_subscription_status_active" ) )
{
$startdate = get_user_meta( $user_id, "pmprowoo_startdate_$level_id", true );
if( !empty($startdate) )
{
$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->pmpro_memberships_users SET startdate = %s WHERE user_id = %d AND status = 'active'", $startdate, $user_id ) );
}
@LMNTL
LMNTL / my_pmprosl_custom_shortcode.php
Created July 24, 2019 00:07
Use a custom social login shortcode with PMPro Social Login (Requires v.3 or above)
//use a custom social login shortcode with PMPro Social Login (Requires v.3 or above)
function my_pmprosl_custom_shortcode($shortcode)
{
// edit this line to change the shortcode displayed on the checkout page
return '[TheChamp-Login title="Use your Social Account to Login"]';
}
add_filter("pmprosl_login_shortcode", "my_pmprosl_custom_shortcode");
@LMNTL
LMNTL / my_pmpromd_profile_preheader.php
Created July 22, 2019 18:44
show a 404 page when trying to access a profile page for members with "Hide from Directory?" checked and/or don't have a specific level
//show a 404 page when trying to access a profile page for members with "Hide from Directory?" checked and/or don't have a specific level
function my_pmpromd_profile_preheader()
{
// -------- Edit this line to determine which levels get profile pages ---------- //
$directory_levels = array(1, 2, 3);
global $post, $pmpro_pages, $current_user, $wp_query;
if(!empty($post->ID) && $post->ID == $pmpro_pages['profile'])
{
//Get the profile user
@LMNTL
LMNTL / my_pmproet_email_data.php
Last active July 22, 2019 15:13
properly show variables when using Email Templates Add On with Recurring Payment Reminders
// properly show variables when using Email Templates Add On with Recurring Payment Reminders
function my_pmproet_email_data( $data, $pmproemail )
{
if( $_REQUEST["action"] === 'pmproet_send_test' && $pmproemail->template === 'membership_recurring' )
{
$euser = get_user_by( "email", $pmproemail->email );
// Make sure we have a user.
if ( empty( $euser ) ) {
return $body;