Skip to content

Instantly share code, notes, and snippets.

View davidmutero's full-sized avatar

David Mutero davidmutero

View GitHub Profile
@davidmutero
davidmutero / sequential-numeric-member-number-level-specific.php
Last active October 30, 2024 14:11 — forked from michaelbeil/sequential-numeric-member-number.php
Generates and displays sequential numbers for members of a designated level on account, profile, members list, card, and CSV export.
<?php
/**
* Sequential Membership Numbers for designed membership level e.g Membership Level 2 Only
*
* This forked version generates sequential membership numbers only for users registered at Membership Level 2.
* Member numbers are automatically increased from the starting value set for $starting_member_number
* after each new Level 2 member registration.
*
* Displayed on user account, edit profile, members list pages, membership card, and included in members list CSV export.
*
@davidmutero
davidmutero / my-persistent-login-for-all-users.php
Last active October 31, 2024 14:13 — forked from ipokkel/my-persistent-login.php
Extends the user login period to one year for all users, regardless of the "Remember Me" option.
<?php
/**
* Plugin Name: Persistent Login for All Users
* Description: Extends the user login period to one year for all users, regardless of the "Remember Me" option.
* Version: 1.0
* Author: Your Name
*
* @link https://developer.wordpress.org/reference/hooks/auth_cookie_expiration/
*
* Usage: This plugin extends the login period for all users to one year without requiring them to select the "Remember Me" option.
@davidmutero
davidmutero / pmpro-expiration-date-cutoff-adjustment.php
Last active December 3, 2024 16:29 — forked from ipokkel/pmprosed-extend-expiration-date-from-set-date.php
This custom snippet adjusts the expiration dates for Paid Memberships Pro memberships based on a specific cutoff date.
<?php
/**
* Adjust expiration date based on a defined cutoff date for Paid Memberships Pro.
*
* If a user signs up or renews on or after the defined cutoff date,
* their membership expiration date is extended by a specified period
* (e.g., December 31 of the next year).
* If they sign up or renew before the cutoff, the expiration date
* is set to a different period (e.g., December 31 of the current year).
*
@davidmutero
davidmutero / disable-any-automatic-phone-number-formatting-in-paid-memberships-pro.php
Last active December 16, 2024 09:54 — forked from ipokkel/pmpro_format_my_phone.php
Disable any automatic phone number formatting in Paid Memberships Pro
<?php
/**
* Disable any automatic phone number formatting in Paid Memberships Pro.
*
* This ensures phone numbers are displayed exactly as entered by the member.
*
* Add this code to your PMPro Customizations Plugin
* - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
@davidmutero
davidmutero / update-user-nicename-after-username-change.php
Created December 24, 2024 13:18
Update the user_nicename field in the database after changing a username.
<?php
/**
* Update the user_nicename field in the database after changing a username.
*
* Use this snippet after updating a user's username (user_login) using a plugin like
* "Easy Username Updater" or similar tools. This ensures that the profile URL updates
* correctly by setting the user_nicename field to match the updated username.
*
* Instructions:
* 1. Add this snippet to your theme's functions.php file or use a code snippets plugin.
@davidmutero
davidmutero / pmpro_multisite_nginx_restrict_docs.conf
Created December 30, 2024 10:44
Locking down files with Paid Memberships Pro using NGINX for Multisite Setup
# For subsites
rewrite ^\/wp-content\/uploads\/sites\/([0-9]+)\/(.*[\.pdf|\.doc|\.docx|\.ppt|\.zip])$ /wp-content/plugins/paid-memberships-pro/services/getfile.php?blog_id=$1&file=$2 last;
# For the main site
rewrite ^\/wp-content\/uploads\/(.*[\.pdf|\.doc|\.docx|\.ppt|\.zip])$ /wp-content/plugins/paid-memberships-pro/services/getfile.php?file=$1 last;
@davidmutero
davidmutero / my_pmprodon_donation_notes.php
Last active February 14, 2025 15:27 — forked from ideadude/my_pmprodon_donation_notes.php
Donation notes field example for PMPro Donations (Updated).
<?php
/**
* Donation notes.
* Edit the copy below.
* Add to a custom plugin.
* Notes are now saved into the order meta instead of the order notes.
*/
// Show the donation notes field at checkout (Always visible)
@davidmutero
davidmutero / mypmpro-change-price-plus-payment-plan-based-on-gateway.php
Last active February 5, 2025 14:29 — forked from JarrydLong/mypmpro-change-price-based-on-gateway.php
Add a fee to the initial and recurring value when using Stripe including when a payment plan is selected.
<?php
/**
* This recipe will add a fee to the initial and recurring value when using Stripe
* including when a payment plan is selected.
*
* 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/
*/
@davidmutero
davidmutero / pmpro-add-website-field-checkout-profile-admin.php
Last active February 7, 2025 14:12 — forked from ipokkel/default-wordpress-website-and-biographical-fields.php
Collect the default WordPress user fields for Website Field URL (user_url) and show on PMPro Checkout, Profile Edit, and Admin Member Edit
<?php
/**
* Add Website Field to PMPro Checkout, Frontend Profile Edit, and Admin Member Edit Screen.
*
* - Adds a "Website" field to checkout, user profile edit, and admin member edit screen.
* - Saves the website URL correctly to the default WordPress `user_url` field.
*/
/**
* Add Website field to PMPro Checkout Form.
@davidmutero
davidmutero / add-a-state-in-pmpro-state-dropdown-add-on.php
Created February 25, 2025 10:18
Add A State in PMPro State Dropdown Add On
<?php
/**
* Add a custom state/region to a specific country in the PMPro State Dropdown Add On.
*
* This ensures the new state/region appears in alphabetical order within the country's list.
* Modify `$country_code` and `$custom_state` as needed for your use case.
*
* 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: