Skip to content

Instantly share code, notes, and snippets.

View dparker1005's full-sized avatar

David Parker dparker1005

  • Stranger Studios
View GitHub Profile
@dparker1005
dparker1005 / my_pmpro_fix_taxonomy_user_field_data.php
Last active March 31, 2023 10:29
On login, loop through all user fields and check if any are taxonomy fields. If so, check the user's meta value for that field. If the taxonomy option label is stored, change it to the ID.
<?php
// Copy from below here...
/**
* On login, loop through all user fields and check if any are taxonomy fields.
* If so, check the user's meta value for that field. If the taxonomy option label
* is stored, change it to the ID.
*
* Upgrade script to go along with this bug fix PR: https://github.com/strangerstudios/paid-memberships-pro/pull/2423
@dparker1005
dparker1005 / pmpro_allowlist.php
Created March 22, 2023 14:54
Only allow specific email addresses and usernames to check out using PMPro. Forked from Register Helper.
<?php
/*
* Plugin Name: PMPro Allowlist
* Plugin URI: https://www.paidmembershipspro.com
* Description: Only allow specific email addresses and usernames to check out using PMPro. Forked from Register Helper.
* Version: 1.0
* Author: Paid Memberships Pro
* Author URI: https://www.paidmembershipspro.com
*/
@dparker1005
dparker1005 / redirect_cancel_to_stripe.php
Created March 9, 2023 18:54
Redirect users from the cancellation page to the Stripe Customer Portal.
<?php
// Copy from below here...
/**
* Prevent users from cancelling their membership or checking out for a new one.
*/
function my_pmpro_redirect_cancel_to_stripe() {
global $pmpro_pages;
if ( ! empty( $pmpro_pages['cancel'] ) && is_page( $pmpro_pages['cancel'] ) ) {
@dparker1005
dparker1005 / my_pmpro_prevent_name_save_at_checkout.php
Created March 8, 2023 15:14
Do not update user's first and last name while on the PMPro Checkout page. Useful if you do not want the user's billing name to be the name on the account.
<?php
// Copy from below here.
/**
* Do not update user's first and last name while on the PMPro Checkout page.
* Useful if you do not want the user's billing name to be the name on the account.
*/
function my_pmpro_prevent_name_save_at_checkout( $check, $object_id, $meta_key ) {
if ( $meta_key === 'first_name' || $meta_key === 'last_name' ) {
@dparker1005
dparker1005 / my_pmpromb_hide_default_badges.php
Created December 13, 2022 17:54
Hide default member badges. Useful if some of your levels should not show badges.
<?php
// Copy from below here...
/**
* Hide default member badges. Useful if some of your levels should not show badges.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
@dparker1005
dparker1005 / default_option_email_admin_checkout.php
Last active December 12, 2022 18:30
Send admin checkout emails when using the PMPro Multiple Memberships per User Add On.
<?php
// Copy from below here...
/**
* Send admin checkout emails when using the PMPro Multiple Memberships per User Add On.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
@dparker1005
dparker1005 / webhook-cancelled-email.php
Created November 28, 2022 15:21
If the cancellation email is being sent because of a cancelled payment subscription, then send a different email body.
<?php
// Copy from below this line.
/**
* If the cancellation email is being sent because of a cancelled payment subscription,
* then send a different email body.
*/
function my_pmpro_email_body_cancelled_subscription( $body, $email ) {
if ( $email->template == 'cancel' && pmpro_doing_webhook() ) {
@dparker1005
dparker1005 / my_template_redirect_network_require_membership_access.php
Created November 10, 2022 16:07 — forked from kimcoleman/my_template_redirect_network_require_membership_access.php
Redirects members-only content to the Membership Levels page on the Main Network Site if a user is logged out or not a member.
<?php
/*
* Redirects members-only content to the Membership Levels page on the Main Network Site
* if a user is logged out or not a member.
*/
function my_template_redirect_network_require_membership_access() {
if ( function_exists( 'pmpro_has_membership_access' ) && ! pmpro_has_membership_access() ) {
wp_redirect( network_site_url( 'levels' ) );
exit;
@dparker1005
dparker1005 / my_pmpro_checkout_level_round_down_initial_payment.php
Last active October 27, 2022 15:53
Round down initial payment price for users switching levels. Useful to make prorated prices look more friendly.
<?php
// Copy from below here...
/*
* Round down initial payment price for users switching levels.
* Useful to make prorated prices look more friendly.
*/
function my_pmpro_checkout_level_round_down_initial_payment( $level ) {
// We only want to round down prorations.
@dparker1005
dparker1005 / log_create_recurring_payments_profile_response.php
Created August 22, 2022 12:39
Creates a log at /paid-memberships-pro/logs/create_recurring_payments_profile_response.txt for whenever we create a recurring payment profile in PayPal.
<?php
// Copy from below here...
/*
* Creates a log at /paid-memberships-pro/logs/create_recurring_payments_profile_response.txt for whenever we create
* a recurring payment profile in PayPal.
*
* Useful for debugging a "Missing PROFILESTATUS" error or initial subscription orders in "error" status.
*/