Skip to content

Instantly share code, notes, and snippets.

View ipokkel's full-sized avatar

Theuns Coetzee ipokkel

View GitHub Profile
@ipokkel
ipokkel / pmpro-change-recipient-for-billing-emails.php
Created April 25, 2024 07:05
Change the email recipient for a specified set of email templates if the intended recipient has an alternative recipient email address set as user meta.
<?php
/**
* Change the recipient for billing emails to an additional email address.
*
* 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.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_change_recipient_for_billing_emails( $user_email, $email ) {
@ipokkel
ipokkel / remove-cancel-button-for-levels-with-expiration-date.php
Last active April 23, 2024 16:11
Remove the "Cancel" link for levels with an epiration date on the PMPro Account page.
<?php
/**
* Remove the "Cancel" link for levels with an epiration date on the PMPro Account page.
*
* 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.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
@ipokkel
ipokkel / pmpro-block-checkout-if-has-membership-level.php
Last active April 23, 2024 12:59
Stop and prevent members from checking out for a membership level they are already a member of.
<?php
/**
* Prevent users from checking out for a specific set of levels if they already have that level.
*
* Set the $blocked_levels array to the level ids you want to block in each function.
*
* 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.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
<?php
/**
* Show the WordPress Toolbar for custom roles.
*
* This is helpful if users have multiple roles.
*
* For example, if you have a role "subscriber" and a role "pmpro_memberships_manager"
* or "pmpro_approver" and you want to show the toolbar for the those roles.
*
* You can add this recipe to your site by creating a custom plugin
@ipokkel
ipokkel / pmpro-3-cancel-immediately.php
Created April 18, 2024 09:21
Cancel a membership level immediately instead of setting the expiration date until the next payment date.
<?php
/**
* Cancel an automatically recurring payment membership level immediately
* when a user cancels their membership level.
*
* 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.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
<?php
/**
* Add a gateway column to the member edit orders page.
*
* 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.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
@ipokkel
ipokkel / hide-stripe-billing-address-fields.php
Last active April 12, 2024 12:29
Force remove Stripe billing fields on checkout and billing
<?php // Do NOT copy this line
function hide_address_on_billing_update_if_stripe() {
global $pmpro_pages, $gateway;
// Bail if necessary
if ( empty( $pmpro_pages ) || ( ! is_page( $pmpro_pages['checkout'] ) && ! is_page( $pmpro_pages['billing'] ) ) ) {
return;
}
// Filter out Stripe billing fields
if ( ! empty( $gateway ) && 'stripe' === $gateway ) {
@ipokkel
ipokkel / show-pmpro-shipping-address-fields-on-member-edit.php
Created April 12, 2024 07:31
Show and edit the Shipping Address fields on the Member Edit page for PMPro 3.0 and newer.
<?php
/**
* Show PMPro shipping address fields on the member edit page.
*
* 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.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function show_pmpro_shipping_address_fields_on_member_edit() {
@ipokkel
ipokkel / add-order-notes-column-and-csv-export.php
Created August 18, 2022 13:03
Add PMPro Order Notes column to the Orders page and include notes in orders export CSV
<?php
/**
* Display Order notes on the PMPro Orders page and include order notes in the PMPro Orders CSV export.
*
* 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.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/