Skip to content

Instantly share code, notes, and snippets.

View dwanjuki's full-sized avatar

David Wanjuki dwanjuki

  • Nairobi, Kenya
  • 05:14 (UTC +03:00)
View GitHub Profile
@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 / 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_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/
<?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/
*/
@dwanjuki
dwanjuki / my_pressidium_analytics_cookie_consent_granted.php
Last active November 17, 2025 14:54 — forked from JarrydLong/mypmpro-cookies-cookiebot-compat.php
Disable pmpro_visit cookie if the user has not consented to Analytics cookies via the Pressidium Cookie Consent plugin.
@dwanjuki
dwanjuki / pmpro-tag-delete-inactive-users.php
Last active October 27, 2025 09:11 — forked from kimcoleman/pmpro-tag-delete-inactive-users.php
Script to tag and delete inactive PMPro Members and users from WordPress.
<?php
/**
* Script to locate, tag, export, then delete inactive users in your Paid Memberships Pro / WordPress website.
*
* Once this snippet is in the site, admins can run the process by visiting /?delete_inactive_users=1 in the WordPress admin.
* Always back up user data before running any bulk delete script and remove this code after the process is done.
*/
function my_register_user_activity_taxonomy() {
register_taxonomy(
'my_user_activity',
<?php
/**
* This recipe will check if a member has an active level associated with
* their account. It will add either 'active' or 'inactive' to QR code's data.
*
* Set your shortcode to [pmpro_membership_card qr_code='true' qr_data='other']
* for this filter to take effect.
*
* 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.
@dwanjuki
dwanjuki / pmpro-invoice-bullets-example.php
Last active September 29, 2025 10:46 — forked from ipokkel/pmpro-invoice-bullets-example.php
Display Company Name as a bullet on the PMPro Invoice
<?php
/**
* Display Company Name as a bullet on the PMPro Invoice.
*
* 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 / pmpro-approvals-bcc-admin-emails-to-users-with-pmpro-approvals-capability.php Send a copy of PMPro Approval admin notification emails to users that have the pmpro_approvals capability. This should include users that has the pmpro_approver role or the pmpro_membership_manager role role.
<?php
/**
* Bcc admin approval emails to users with pmpro_approvals capability.
*
* 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 pmpro_approvals_bcc_admin_notification_emails( $headers, $email ) {