Skip to content

Instantly share code, notes, and snippets.

View andrewlimaza's full-sized avatar

Andrew Lima andrewlimaza

View GitHub Profile
@andrewlimaza
andrewlimaza / allow-iframe-wp-kses-post.php
Created December 19, 2025 14:21
Allow <iframe> in content around wp_kses_post functions
<?php
/**
* Allow <iframe> code in wp_kses_post calls.
* Useful for embedding videos in Memberlite theme banner descriptions.
*
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_allow_iframe_wp_kses_post( $tags, $context ) {
if ( 'post' === $context ) {
@andrewlimaza
andrewlimaza / change-pmprorate-downgrade-text.php
Created December 17, 2025 12:38
Replace !!pmprorate_downgrade_text!! wording using gettext
<?php
/**
* Change the wording of the Prorations Downgrade Text.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/documentation/templates/customizing-via-a-custom-plugin/
*/
function my_pmpro_change_text( $translated_text, $text, $domain ) {
if ( $domain == 'pmpro-proration' ) {
if ( $text == 'Downgrading to %s on %s.' ) {
$translated_text = 'Changing to %s on %s.'; // Adjust the wording here.
}
@andrewlimaza
andrewlimaza / remove-html-comments-from-source.php
Created November 26, 2025 11:58
Remove HTML comments from source code for WordPress sites.
<?php
/**
* Remove all comments from HTML source (<!-- some comment -->)
* Use at your own risk.
*
* To add customizations to your site, please follow this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
// Strip out HTML comments from the buffer.
function my_pmpro_strip_html_comments( $buffer ) {
@andrewlimaza
andrewlimaza / order.html
Created October 18, 2025 22:30
Example template of using Noto Sans JP (Japanese) for PDF Generation
<!DOCTYPE html>
<html>
<head>
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@300;400;700&display=swap" rel="stylesheet">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<meta http-equiv="content-type" content="text-html; charset=utf-8">
<style type="text/css">
html, div, p, table {
font-family: 'Noto Sans JP', sans-serif;
}
@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';
}