Skip to content

Instantly share code, notes, and snippets.

Avatar

Jessica Thomas LMNTL

View GitHub Profile
@LMNTL
LMNTL / my_pmpro_email_headers_admin_emails.php
Last active Oct 30, 2020 — forked from strangerstudios/my_pmpro_email_headers_admin_emails.php
BCC an additional email on PMPro admin emails. Works with PMPro Approvals emails.
View my_pmpro_email_headers_admin_emails.php
/*
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 Sep 4, 2019
don't require the "State" field at checkout and hide it
View custom_stylesheet.css
.pmpro_checkout-field-bstate {
display: none;
}
@LMNTL
LMNTL / pmpromh_modified_login_redirect.php
Last active Sep 4, 2019
preserve requested redirect with PMPro Member Homepages
View pmpromh_modified_login_redirect.php
// 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 Aug 23, 2019
don't cancel memberships when woocommerce orders go on hold
View my_pmpro_woocommerce_on_hold_keep_membership.php
// 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 Aug 13, 2019
Change cancellation to set expiration date for next payment instead of cancelling immediately. (updated 8/13/19)
View my_pmpro_before_change_membership_level_customization.php
/*
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 Aug 12, 2019
Remove shipping address from PMPro-generated emails when using Shipping Add On
View my_pmproship_remove_email_filter.php
// 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 Aug 15, 2019
preserve start date when PMPro WooCommerce subscriptions go into "on hold" status
View my_pmprowoo_on_hold_keep_startdate.php
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 Jul 24, 2019
Use a custom social login shortcode with PMPro Social Login (Requires v.3 or above)
View my_pmprosl_custom_shortcode.php
//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 Jul 22, 2019
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
View my_pmpromd_profile_preheader.php
//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 Jul 22, 2019
properly show variables when using Email Templates Add On with Recurring Payment Reminders
View my_pmproet_email_data.php
// 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;