Skip to content

Instantly share code, notes, and snippets.

View dwanjuki's full-sized avatar

David Wanjuki dwanjuki

  • Nairobi, Kenya
  • 05:02 (UTC +03:00)
View GitHub Profile
@dwanjuki
dwanjuki / my_pmpromd_remove_hide_directory_field.php
Created March 30, 2026 09:05
Remove "Hide from PMPro Directory?" checkbox from checkout and member profile edit page
<?php
/**
* Remove "Hide from PMPro Directory?" checkbox from checkout and member profile edit.
*
* 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_remove_hide_directory_field() {
@dwanjuki
dwanjuki / my_pmpromd_hide_fields_member_profile_edit.php
Created March 27, 2026 11:32
Hide Member Directory fields on the frontend Member Profile Edit page
<?php
/**
* Set Member Directory User Fields profile visibility to admin.
*
* 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_fields_member_profile_edit() {
@dwanjuki
dwanjuki / login-redirect-admin-and-users.php
Last active March 27, 2026 09:39 — forked from ipokkel/pmpro-login-redirect-admin-and-users.php
Redirect administrators to the WP Admin Dashboard and other users to the specified page on login.
<?php
/**
* Redirect Administrators to WP Admin,
* redirect all other users to the specified page after login.
*
* Ignores previously set redirects.
*
* 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 / my_pmpro_has_membership_access_filter_cpt.php
Created March 27, 2026 09:10
Restrict access to Custom Post Type based on membership level.
<?php
/**
* Restrict access to CPT based on membership level.
*
* Ref: https://www.paidmembershipspro.com/hook/pmpro_has_membership_access_filter_post_type/
*
* 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 / cleanup-bua.php
Last active March 26, 2026 12:26 — forked from kimcoleman/cleanup-bua.php
Admin queryable/Non WP-CLI Cleanup script: Remove Basic User Avatars meta + files after PMPro migration.
<?php
/**
* Cleanup script: Remove Basic User Avatars meta + files after PMPro migration.
* Use the migration script first.
*
* Trigger from wp-admin URL:
* - /wp-admin/?pmpro_avatar_cleanup=1&dry_run=1 (dry run)
* - /wp-admin/?pmpro_avatar_cleanup=1&dry_run=0 (real cleanup)
*
* Check PHP error log for output.
@dwanjuki
dwanjuki / pmpro_migrate_basic_user_avatars.php
Last active March 26, 2026 12:20 — forked from kimcoleman/pmpro_migrate_basic_user_avatars.php
Admin queryable/Non WP-CLI Migration script: Basic User Avatars → PMPro Avatars
<?php
/**
* Migration script: Basic User Avatars → PMPro Avatars
*
* To trigger, visit one of:
* - /wp-admin/?pmpro_avatar_migrate=1&dry_run=1 (dry run)
* - /wp-admin/?pmpro_avatar_migrate=1&dry_run=0 (real migration)
*
* Check PHP error log for progress output.
*
@dwanjuki
dwanjuki / my_pmproan2c_middle_name_user_field.php
Last active March 24, 2026 13:47
Reposition a Middle Name User Field between the First Name and Last Name fields from the Add Name to Checkout Add On.
<?php
/**
* Reposition a Middle Name User Field between the First Name and Last Name
* fields from the Add Name to Checkout Add On.
*
* Note: The field's name must be middle_name, label can be something else.
*
* 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 / my_pmpro_member_read_only_fields_js.php
Created March 17, 2026 11:26 — forked from ipokkel/lock-down-first-and-last-name.php
Make First Name, Last Name and a custom field read-only for non-admin users
<?php
/**
* This recipe assigns the readonly attribute to the fields
* first_name, last_name, and date_de_naissance on profile edit pages
* for non-admin users.
*
* 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_search_form_required_js.php
Created March 10, 2026 10:49
Make the Member Directory search field required.
<?php // copy from below.
/*
* Make the Member Directory search field required.
* Display a custom validation message if the field is left blank.
*
* 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_disable_bp_activity_page.php
Last active March 9, 2026 15:34
Hide BuddyPress activity from members pending approval.
<?php
/**
* Hide BuddyPress activity from members pending approval.
*
* 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/
*/