Skip to content

Instantly share code, notes, and snippets.

View dwanjuki's full-sized avatar

David Wanjuki dwanjuki

  • Nairobi, Kenya
  • 10:39 (UTC +03:00)
View GitHub Profile
@dwanjuki
dwanjuki / my_pmpro_plus_icon_in_title.php
Last active July 3, 2026 13:57
Add custom content before title of posts with protected content
<?php
/**
* Add custom content before title of posts with protected content
*
* 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 / charge-billing-amount-on-renewal.php
Created July 2, 2026 11:33
Charge the level's Billing Amount instead of the Initial Payment when an existing member checks out to manually renew their current level.
<?php
/**
* Charge the level's Billing Amount instead of the Initial Payment when an
* existing member checks out to manually renew their current level.
*
* Only applies to members who have been continuously active on that level
* for at least the number of months set in MY_PMPRO_RENEWAL_ACTIVE_MONTHS below.
*
* 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.
<?php
/**
* This recipe requires members to apply and be approved for the "application" level
* again before rejoining a "main" level after their main membership has ended.
*
* For this recipe to work, you must be using the Approvals Add On and your main
* levels must be set to "Yes. User must have an approved membership for a different
* level." or "Yes. User must have an approved membership for a different level AND
* admin must approve new members for this level." under the Approval Settings when
* editing the membership level. Other approval and non-approval levels will not
@dwanjuki
dwanjuki / apply-tax-for-ALL-UK-customers.php
Created June 30, 2026 08:28
VAT Tax Add On: Apply tax for ALL UK customers
<?php
/**
* Apply tax for ALL UK customers
*
* Requires VAT Tax 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.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
<?php
/**
* This ensures that the UK can be selected from the dropdown to add Tax to the
* membership but will not validate the VAT number.
*
* 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
/**
* Require Approval for Every Signup (with admin notification)
*
* Forces every checkout for an approval-required level back to "pending",
* so a previously-approved member (e.g. one whose membership expired) must
* be manually re-approved before regaining access.
*
* It also makes sure the admin "pending approval" email is sent for those
* returning members.
@dwanjuki
dwanjuki / member-directory-profile-welcome-message-shortcode.php
Created June 23, 2026 09:27
Shortcode to display "Welcome to (member name)'s Profile" on PMPro Member Directory profile pages.
<?php
/**
* Shortcode to display "Welcome to (member name)'s Profile"
* on PMPro Member Directory profile pages.
*
* Usage: [pmpro_profile_welcome]
*
* 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.
@dwanjuki
dwanjuki / use-company-name-field-value-as-username-at-checkout.php
Created June 22, 2026 15:18
Use the "company_name" custom field as the WordPress username at PMPro checkout
<?php
/**
* Use the "company_name" custom field as the WordPress username at PMPro 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/
*/
<?php
/**
* Hide Tutor LMS assignments from course content and block direct assignment
* access for members who do not hold an allowed PMPro 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/
*/
@dwanjuki
dwanjuki / my_pmpromd_show_hide_directory_field_for_specific_levels.php
Created June 3, 2026 11:20
Show "Hide from PMPro Directory?" checkbox for specific membership levels only
<?php
/**
* Show "Hide from PMPro Directory?" checkbox for specific membership levels only.
* By default, the field shows only on the frontend profile page for all members.
*
* 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/
*/