Skip to content

Instantly share code, notes, and snippets.

View andrewlimaza's full-sized avatar

Andrew Lima andrewlimaza

View GitHub Profile
@andrewlimaza
andrewlimaza / example-pmpro-date-field-min-max.php
Created October 13, 2025 09:25
PMPro Date Field limit minimum and maximum dates
<?php
// Example of using min and max input fields for date fields.
function my_pmpro_add_user_fields() {
// Don't break if PMPro is out of date or not loaded.
if ( ! function_exists( 'pmpro_add_user_field' ) ) {
return false;
}
// Store our field settings in an array.
@andrewlimaza
andrewlimaza / pmpro-show-group-on-directory-profile.php
Created September 29, 2025 07:28
Show Membership Groups on Directory Profile Page for Paid Memberships Pro - Member Directory
<?php
/**
* Shows membership level groups on the frontend profile page of the PMPro Membership Directory Add On.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_show_level_group_on_user_profile( $user ) {
$levels = pmpro_getMembershipLevelsForUser( $user->ID );
if ( empty( $levels ) ) {
@andrewlimaza
andrewlimaza / addon-packages-view-as-admins.php
Created September 23, 2025 12:06
Add support for "View As" which allows admins access to Addon Packages when set to "true"
<?php
/**
* Give access to admins to Addon Packages when "View As" is enabled.
*
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmproap_support_admin_view_as( $levels, $user_id, $post_id ){
if ( current_user_can( 'manage_options' ) ) {
$view_as = get_user_meta( $user_id, 'pmpro_admin_membership_access', true );
@andrewlimaza
andrewlimaza / example-change-sub-delay-filter.php
Created September 9, 2025 07:56
Filter the subscription delay option for level ID 2 example.
<?php
/**
* Filter the subscription delay option for membership level ID 2 to be 1 year later if checking out in October.
* Change "option_pmpro_subscription_delay_2" to "option_pmpro_subscription_delay_X" for a specific membership level.
*
* @see https://developer.wordpress.org/reference/hooks/option_option/
*
* Add this custom code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_adjust_sub_delay_date( $value, $option ) {
@andrewlimaza
andrewlimaza / ffl_pmpro_member_panel.php
Last active April 24, 2025 06:21
Force First and Last Name as Display Name with Paid Memberships Pro Edit Member
<?php
/**
* Enable functionality for the Edit Member Panel when saving user info.
* Add this code to your site, follow this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
**/
function my_custom_ffl_fix_user_display_name() {
// Make sure Force First and Last Name is installed.
if ( ! function_exists( 'ffl_fix_user_display_name' ) ) {
return;
@andrewlimaza
andrewlimaza / force-sv-locale-pmpro.php
Created March 31, 2025 13:30
Force "sv" for locale for Paid Memberships Pro "sv_SE" locales
<?php
/**
* Force the locale to be `-sv.mo/.po` if `sv_SE` is detected as the locale.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* This should resolve issues temporarily if you are using Swedish Locale.
**/
function my_pmpro_force_locale_for_swedish( $locale, $plugin ) {
if ( $plugin === 'paid-memberships-pro' && $locale === 'sv_SE' ) {
$locale = 'sv';
}
@andrewlimaza
andrewlimaza / my-pmpro-approvals-denied-message.php
Last active February 19, 2025 08:44
Custom !!denied_reason!! for Approvals Denied Email Templates.
<?php
/**
* Add a custom field !!denied_reason!! to be used in Approvals Denied Email.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_denied_message( $data, $member ) {
$denied_reason = get_user_meta( $member->ID, 'my_field_key', true ); // Change 'my_field_key' to the meta key of your custom field.
$data['denied_reason'] = $denied_reason;
return $data;
}
@andrewlimaza
andrewlimaza / pmpro-trigger-recent-members-limit.php
Created February 4, 2025 06:10
Adjust the number of member records sent to Zapier from Paid Memberships Pro.
<?php
/**
* Adjust the number of records sent within a single Zapier trigger for Paid Memberships Pro.
* Default is 1 per run.
* To add this code to your WordPress site, please follow this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_trigger_recent_members_limit( $limit ) {
return 20;
}
add_filter( 'pmpro_trigger_recent_members_limit', 'my_pmpro_trigger_recent_members_limit', 10, 1 );
@andrewlimaza
andrewlimaza / change-set-expiration-date-programmatically.php
Created January 2, 2025 12:35
Programmatically change the Set Expiration Date from Y1 to Y2 when checkout is in October, November or December.
/**
* Adjust the Set Expiration Date Add On programmatically.
* Automatically adjust Y1-12-31 to be Y2-12-31 if the current month is October or later.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_programmatically_change_set_expiration_date( $raw_date ) {
// No Set Expiration Date, just bail.
if ( empty( $raw_date ) ) {
return $raw_date;
@andrewlimaza
andrewlimaza / pmpro-before-submit-button-text.php
Created December 31, 2024 07:28
Add small notice above submit button that charges are in USD for Paid Memberships Pro
<?php
/**
* Add a small message above the submit button at checkout that charges will be done in USD.
* To add this code to your site, please follow this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_add_message_before_submit_button() {
echo "<em>Please note that all charges will be processed in USD (United States Dollars).</em>";
}
add_action( 'pmpro_checkout_before_submit_button', 'my_pmpro_add_message_before_submit_button' );