Skip to content

Instantly share code, notes, and snippets.

Avatar

Jason Coleman ideadude

View GitHub Profile
@ideadude
ideadude / my_pmpro_checkout_level.php
Last active Apr 19, 2021 — forked from strangerstudios/my_pmpro_checkout_level.php
Increase price at checkout if a certain value (e.g. added via PMPro Register Helper) is set.
View my_pmpro_checkout_level.php
<?php
/**
* If a user checked option1, then add $100 to the price.
*/
function my_pmpro_checkout_level($level) {
if( ! empty( $_REQUEST['option1'] ) || ! empty( $_SESSION['option1'] ) ) {
$level->initial_payment = $level->initial_payment + 100;
//$level->billing_amount = $level->billing_amount + 100; //to update recurring payments too
}
@ideadude
ideadude / my_get_rh_option_label.php
Created Apr 5, 2021
Look up the label of an option for a PMPro Register Helper field.
View my_get_rh_option_label.php
<?php
/**
* Look up the label of an option for a Register Helper field.
* @param $field_name The name of the field (user meta key)
* @param $option_key The key of the option in the fields options array.
* @returns The label for the field or "N/A" if none found.
*/
function my_get_rh_option_label( $field_name, $option_key ) {
global $pmprorh_registration_fields;
@ideadude
ideadude / my_sort_bp_members_list.php
Created Apr 5, 2021
Sort BuddyPress members by PMPro membership level.
View my_sort_bp_members_list.php
/**
* Sort BuddyPress members by PMPro membership level.
* Add this code as a code snippet or in a custom plugin.
* https://www.paidmembershipspro.com/how-to-add-code-to-wordpress/
*/
function my_sort_bp_members_list( $query ) {
global $wpdb;
$query->uid_clauses['select'] .= " LEFT JOIN $wpdb->pmpro_memberships_users mu ON u.user_id = mu.user_id AND mu.status = 'active' ";
$query->uid_clauses['orderby'] = str_replace( 'ORDER BY', 'ORDER BY mu.membership_id DESC, ', $query->uid_clauses['orderby'] );
}
@ideadude
ideadude / my_fix_billing_amount.php
Created Apr 2, 2021
Fix the billing amount shown on a user's account with Paid Memberships Pro
View my_fix_billing_amount.php
<?php
/**
* Change the billing amount and cycle number/period for a user's active membership.
* This is useful if the number is out of alignment with the gateway.
* Change the variables under "change this stuff"
* Then visit /wp-admin/?my_fix_billing_amount=1 as an admin.
* Deactivate this snippet after running.
*/
function my_fix_billing_amount() {
global $wpdb;
@ideadude
ideadude / my_keep_free_members_in_old_members_list.php
Created Mar 30, 2021
Keep "old" members who expired or cancelled in the old members lists even if they have a free level now. Paid Memberships Pro.
View my_keep_free_members_in_old_members_list.php
<?php
/**
* When PMPro users cancel or expire, they are shown on the
* cancelled, expired, and "old" members lists.
* However, if an old user is given a default/free level later,
* then they are not considered old, cancelled, or expired anymore.
*
* You may still want to see those users on the old users lists
* so you can follow up to get them back into paid accounts.
* This code does that.
@ideadude
ideadude / pmpro_roles_exclude_other_pmpro_roles.php
Created Mar 23, 2021
Allow admins to set multiple PMPro level roles to one level when using PMPro and the PMPro Roles Add On.
View pmpro_roles_exclude_other_pmpro_roles.php
add_filter( 'pmpro_roles_exclude_other_pmpro_roles', '__return_false' );
@ideadude
ideadude / my_pmpro_email_confirmation_text.php
Created Mar 23, 2021
Change the confirmation text when using PMPro and the Email Confirmation Add On.
View my_pmpro_email_confirmation_text.php
/**
* Change the "IMPORTANT!" confirmation text when using PMPro and the Email Confirmation Add On.
* Add this code into a custom plugin or code snippet.
* Be sure to change the translated lines below to the language and words you want.
* https://www.paidmembershipspro.com/how-to-add-code-to-wordpress/
*/
function my_pmpro_email_confirmation_text( $translated_text, $text, $domain ) {
// Ignore strings for other plugins.
if ( $domain != 'pmpro-email-confirmation' ) {
return $translated_text;
@ideadude
ideadude / my_pmpro_page_templates.php
Created Mar 22, 2021
Load your own templates for Paid Memberships Pro using a custom plugin.
View my_pmpro_page_templates.php
/**
* Include this code in your custom WordPress plugin
* to load your own versions of the PMPro page templates.
* To override the cancel.php template, place your own
* cancel.php template in a folder like this:
* ../plugins/yourpluginslug/templates/cancel.php
*
* Using priority 100 will make sure this runs after
* other code using the smae hook. For example,
* it will run later than the Reason for Cancelling Add On
@ideadude
ideadude / init_test_braintree_webhook.php
Created Mar 5, 2021
Testing the PMPro Braintree using the signature and payload from a webhook log.
View init_test_braintree_webhook.php
<?php
/**
* Add this function into a customizations plugin
* and then visit yoursite.com/wp-admin/?test_braintree_webhook=1 from a browser.
*/
function init_test_braintree_webhook() {
if(!empty($_REQUEST['test_braintree_webhook'])) {
define('PMPRO_BRAINTREE_WEBHOOK_DEBUG', true);
$_POST['bt_signature'] = 'putthesignaturefromthewebhookloghere';
@ideadude
ideadude / pmpro-australia-gst.php
Created Jan 19, 2021 — forked from strangerstudios/pmpro-australia-gst.php
Paid Memberships Pro - Australia GST
View pmpro-australia-gst.php
<?php
/*
Plugin Name: Paid Memberships Pro - Australia GST
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-australia-gst/
Description: Apply Australia GST to Checkouts with PMPro
Version: .1
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
*/
/*