Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View LMNTL's full-sized avatar

Jessica Thomas LMNTL

  • Chicago, IL
View GitHub Profile
<?php
/*
* Give users a new level after x successful payments at another level.
*/
function my_pmpro_after_change_membership_level($level_id, $user_id, $cancel_level)
{
global $wpdb;
// change number of payments here
$payments = 10;
@LMNTL
LMNTL / admin_redirect.php
Last active March 5, 2019 23:18
Change /wp-admin/ Redirect After Login for Paid Memberships Pro
<?php
/* Change /wp-admin/ Redirect After Login for Paid Memberships Pro */
function my_pmpromh_login_redirect( $redirect_to, $request, $user )
{
$admin_url = get_admin_url();
$landing_page_id = 11; //change this to the ID of the page you want to redirect the user to
if ( ! current_user_can( 'administrator' ) && $redirect_to == $admin_url ) {
$redirect_to = get_permalink( $landing_page_id );
}
@LMNTL
LMNTL / pmpro-stripe-billing-limits.php
Last active March 19, 2019 17:18
PMPro Stripe Billing Limits
<?php
/*
Plugin Name: PMPro Stripe Billing Limits
Plugin URI: http://www.paidmembershipspro.com/add-ons/pmpro-stripe-billing-limits/
Description: Allow billing limits with Stripe, where the Stripe subscription is cancelled, but the PMPro membership is not after X payments.
Version: .3
Author: strangerstudios
Author URI: http://www.strangerstudios.com
*/
/*
@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 / customization.php
Last active April 15, 2019 21:52
Allows renewing yearly memberships with a set expiration date. Requires the Set Expiration Dates Add On for Paid Memberships Pro
/*
Allows renewing yearly memberships with a set expiration date.
E.g. if the level expires on 1/1/2020 and the member renews their membership before then, their membership will be extended to 1/1/2021
Requires the Set Expiration Dates Add On for Paid Memberships Pro
*/
function my_pmpro_yearly_membership_renewal($level) {
$extend_level = 1; //change to the level with a set expiration date
if( $level->id == $extend_level && pmpro_hasMembershipLevel( $extend_level ) )
@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;
@LMNTL
LMNTL / pmprorh-validate-on-profile-edit.php
Last active April 26, 2019 20:26
Add custom validation for Register Helper fields when editing from profile page
/*
Add custom validation for Register Helper fields when editing from profile page.
Requires Paid Memberships Pro and Register Helper Add On.
*/
function my_pmprorh_user_profile_validate_rhfields($errors, $update, $user) {
if( isset( $_POST['my_errors'] ) ){
$my_errors = $_POST['my_errors'];
foreach( $my_errors as $single_error){
$errors->add('my_pmprorh_error',__($single_error));
@LMNTL
LMNTL / override-set-expiration-text.php
Created April 23, 2019 19:25
override expiration text for Set Expiration Date Add On for Paid Memberships Pro
/*
Change expiration text on levels page.
*/
function pmprosed_my_pmpro_level_expiration_text($expiration_text, $level)
{
$set_expiration_date = pmpro_getSetExpirationDate($level->id);
if (!empty($set_expiration_date)) {
$set_expiration_date = pmprosed_fixDate($set_expiration_date);
$expiration_text = "This membership level will expire on " . date(get_option('date_format'), strtotime($set_expiration_date, current_time('timestamp'))) . ".";
}
@LMNTL
LMNTL / pmpro_always_show_discount_code.php
Created May 9, 2019 17:12
Always show the top discount code field on the checkout page for Paid Memberships Pro
// Always show the top discount code field on the checkout page for Paid Memberships Pro
function my_pmpro_always_show_discount_code()
{
?>
<script>
jQuery(document).ready(function() {
jQuery('#other_discount_code_tr').show();
jQuery('#other_discount_code_p').hide();
jQuery('#other_discount_code').focus();
});