Skip to content

Instantly share code, notes, and snippets.

View dwanjuki's full-sized avatar

David Wanjuki dwanjuki

  • Nairobi, Kenya
  • 14:03 (UTC +03:00)
View GitHub Profile
@dwanjuki
dwanjuki / my_pmpropbc_added_order_save_fields.php
Created January 19, 2026 12:42
Save User Fields from checkout when a Pay By Check pending order is created.
<?php // copy from below.
/**
* Save User Field values from checkout when a Pay By Check pending order is created.
*
* 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_pmpropbc_added_order_save_fields( $morder ) {
@dwanjuki
dwanjuki / my_pmprovp_remove_fields_discount_code_applied.php
Last active January 15, 2026 10:56
Remove Variable Pricing fields if a discount code is used
<?php
/**
* Remove the Variable Pricing fields if a discount code is applied at checkout.
*
* 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_pmprovp_remove_fields_discount_code_applied( $discount_code, $discount_code_id, $level_id, $code_level ) {
@dwanjuki
dwanjuki / pmpro_hide_billing_address_fields.php
Last active January 15, 2026 08:10
Hide PMPro Billing Address fields
<?php // copy from below.
/**
* Hide PMPro Billing Address fields.
*
* 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/
*/
add_filter( 'pmpro_hide_billing_address_fields', '__return_true' );
@dwanjuki
dwanjuki / my_pmpromd_hide_empty_file_fields.php
Created January 9, 2026 08:45
Hide empty/invalid File type user fields from the directory and profile frontend pages.
<?php
/**
* Hide empty/invalid File user fields on the directory and profile pages.
*
* 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_pmpromd_hide_empty_file_fields( $value, $element, $pu, $displayed_levels ) {
@dwanjuki
dwanjuki / my_pmpro_delete_order_update_discount_code_uses.php
Created December 23, 2025 10:10
Update discount code uses, if found, when an order is deleted
<?php
/**
* Update discount code uses when the order is deleted.
*
* 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_delete_order_update_discount_code( $order_id, $order ) {
@dwanjuki
dwanjuki / my_pmpro_remove_variable_pricing_if_discount_code_applied.php
Created December 22, 2025 11:31
Remove Variable Pricing section at checkout if a valid discount code is passed in via the URL.
<?php
/**
* Remove Variable Pricing section at checkout if a valid discount code is passed
* in via the URL.
*
* 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/
*/
@dwanjuki
dwanjuki / my_pmpro_bcc_membership_recurring_emails.php
Last active January 12, 2026 13:54
BCC the admin on Membership Recurring emails.
<?php
/**
* BCC the admin on Recurring Payment Receipt emails.
*
* 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_bcc_membership_recurring_emails( $headers, $email ) {
<?php
/**
* This recipe will take preference to discount codes. If a discount code is applied
* and is free, the variable price field will be removed.
*
* 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
/**
* Redirect to the PMPro Login page after logout.
*
* 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 wp_redirect_to_pmpro_login_after_logout() {
@dwanjuki
dwanjuki / my_pmpromd_phone_display_value.php
Created December 15, 2025 12:15
Format phone User Field display value in the member directory.
<?php
/**
* Format phone User Field display value in the member directory.
*
* Replace cell_phone on line 14 with your phone field's field name/meta key if different.
*
* 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/