Skip to content

Instantly share code, notes, and snippets.

View ideadude's full-sized avatar

Jason Coleman ideadude

View GitHub Profile
@ideadude
ideadude / pmpro_is_downgrade_custom_filter.php
Last active October 16, 2024 15:19
Override the default is_downgrade check in the PMPro Proration Add On
/**
* Override the default is_downgrade check in the PMPro Proration Add On
* Add this code to a custom plugin.
* A rank of level orders is used to calculate downgrades from upgrades.
* Be sure to change the $level_order array below as needed.
* You can also do your own calculation on the $old_level and $new_level objects.
*/
function pmpro_is_downgrade_custom_filter( $is_downgrade, $old_level, $new_level ) {
// this array contains all of the level ids in order of downgrade -> upgrade
// change this as needed
@ideadude
ideadude / htaccess.txt
Created February 22, 2018 11:07
Redirect all traffic to maintenance.html except /wp-admin/
#redirect everything
RewriteEngine On
RewriteBase /
RewriteRule ^maintenance.html maintenance.html [L] #setup nothing.html with your noth$
RewriteCond %{REQUEST_URI} !^/?(wp-admin)/
RewriteRule ^$ maintenance.html [L]
RewriteCond %{REQUEST_URI} !^/?(wp-admin)/
RewriteRule . / [R,L]
#end redirect everything
@ideadude
ideadude / my_ipn_redirect.php
Created February 23, 2018 13:00
Redirect MEPR IPN URL to the PMPro IPN URL
/*
Redirect MEPR IPN URL to the PMPro IPN URL, e.g.
https://yoursite.com/mepr/notify/onibvz-5w6/ipn =>
https://yoursite.com/wp-admin/admin-ajax.php?action=ipnhandler
Update line 9 to match the IPN URL given to you by MEPR
*/
function my_ipn_redirect() {
if( defined('PMPRO_DIR') && $_SERVER['REQUEST_URI'] === '/mepr/notify/onibvz-5w6/ipn' ) {
require_once(PMPRO_DIR . "/services/ipnhandler.php");
@ideadude
ideadude / my_pmpro_orders_read_only_fields.php
Last active April 7, 2021 03:32
Make all fields editable on the Orders page in the PMPro dashboard
<?php
/**
* Make all fields editable on the Orders page in the PMPro dashboard.
*
*/
function my_pmpro_orders_read_only_fields( $fields ) {
return array();
}
add_filter( 'pmpro_orders_read_only_fields', 'my_pmpro_orders_read_only_fields' );
@ideadude
ideadude / my_pmpro_license_check.php
Created February 24, 2018 00:27
Increase the timeout limit to 20 when making a call to the PMPro License Server
/**
* Increase the timeout limit to 20 when making a call to the PMPro License Server
* Add this code to a custom plugin.
*/
function my_pmpro_license_check( $timeout ) {
return 20;
}
add_filter( 'pmpro_license_check', 'my_pmpro_license_check' );
@ideadude
ideadude / orders-print.php
Created February 26, 2018 18:32
Custom Template for the Print Invoices Page in PMPro with Notes Shown at the Bottom
<?php
/**
* Custom Template for Print Invoices
*
* Copy this file into the paid-memberships-pro/pages/ folder of your active theme's directory.
* If that folder does not exist, create it.
* Keep the name orders-print.php
*/
?>
<!doctype html>
@ideadude
ideadude / add_rh_fields_to_order_notes_via_pmpro_checkout_order.php
Created February 26, 2018 18:34
Add some Register Helper field data to the order notes at checkout.
/**
* Add some Register Helper field data to the order notes at checkout.
*
* 1. Update the $fields_to_add array below with the fields to save into the order notes.
* 2. Make sure PMPro Register Helper is active, the fields you want are setup and being added to the checkout page form.
* 3. Add this code to a custom plugin.
*
* Note that some advanced field types may not store their data in a human readable format.
* You may want to update this function to handle those field types specifically or to use
* nicer labels in the notes/etc.
@ideadude
ideadude / choose_most_expensive_level_for_addon_packages.php
Created March 2, 2018 18:36
Tell PMPro and PMPro Add On Packages to use the user's current level or the most expensive level when checking out for an add on package.
/**
* Use new pmproap_text_level_id filter to choose the user's currenet level OR the most expensive level with access.
* The level with the highest initial payment is chosen.
* Update this code as needed and add to a custom plugin.
*/
function choose_most_expensive_level_for_addon_packages( $text_level_id, $post_id, $user_id, $post_levels ) {
if ( ! pmpro_hasMembershipLevel( $text_level_id, $user_id ) ) {
$highest_initial_payment = 0;
foreach ( $post_levels as $level_id ) {
$level = pmpro_getLevel( $level_id );
@ideadude
ideadude / my_pmpro_emails_custom_template_path.php
Last active April 3, 2021 04:07 — forked from strangerstudios/my_pmpro_emails_custom_template_path.php
Tell PMPro to look in the pages directory of this plugin for PMPro email templates.
<?php
/*
Tell PMPro to look in the pages directory of this plugin for PMPro email templates.
Add this code to a custom plugin.
Make sure that there is a /email/ directory in the plugin directory with your templates in it.
*/
function my_pmpro_email_custom_template_path($default_templates, $page_name) {
$default_templates[] = dirname(__FILE__) . '/email/' . $page_name . '.html';
return $default_templates;
@ideadude
ideadude / directory.php
Last active March 10, 2018 18:38 — forked from strangerstudios/directory.php
PMPro Member Directory Template Code with pk user meta filtering back in.
<?php
/*
Save this file to /themes/{active theme}/paid-memberships-pro/member-directory/tempaltes/directory.php
*/
/*
This shortcode will display the members list and additional content based on the defined attributes.
*/
function pmpromd_shortcode($atts, $content=null, $code="")
{
// $atts ::= array of attributes