Skip to content

Instantly share code, notes, and snippets.

View andrewlimaza's full-sized avatar

Andrew Lima andrewlimaza

View GitHub Profile
@andrewlimaza
andrewlimaza / show-renew-on-account-page.php
Created August 3, 2026 10:29
Show "Renew" on Account page for any member expiring (regardless of days remaining).
<?php
// Show renew link on all levels that have an expiration date on the PMPro account page.
function my_pmpro_expiring_soon_if_member_has_enddate( $expiring_soon, $level ) {
if ( empty( $level->id ) || ! is_user_logged_in() ) {
return $expiring_soon;
}
// Get the current user's membership for this level ID, including its assigned enddate.
$member_level = pmpro_getSpecificMembershipLevelForUser( get_current_user_id(), (int) $level->id );
@andrewlimaza
andrewlimaza / groengraag-trial-single-submit.php
Last active July 27, 2026 07:36
PMPro groengraag.nl - Level 5 checkout: single-click submit button + change wording
<?php
/**
* PMPro - groengraag.nl
* Levels 5 (Groene Try-Out) & 6 (De groene maand) only: prevent the submit
* button being clicked more than once, and change its wording while the form
* submits.
*
* Classic [pmpro_checkout] shortcode. Does NOT disable the <input>, so the
* `submit-checkout` value is still POSTed and checkout completes normally.
*
@andrewlimaza
andrewlimaza / pmpro-pdf-invoices-membership-expiring.php
Created July 13, 2026 07:21
PMPro PDF Invoices add PDF Invoice attachment to "Membership Expiring" emails
<?php
/**
* Include PDF in the membership expiring email.
* This will get the member's last successful order and attach it.
* Add this code to your site by following this guide - https://yoohooplugins.com/customize-wordpress/
*/
add_filter( 'pmpropdf_pdf_included_email_templates', function( $templates ) {
// Add membership_expiring to the list of templates that get PDF invoices
$templates[] = 'membership_expiring';
@andrewlimaza
andrewlimaza / show-premium-tag-pmpro-post-titles.php
Created June 17, 2026 09:21
Show "Premium" next to the title tag for posts in Paid Memberships Pro.
<?php
/**
* Append a "Premium" badge to post titles on archive/blog/search pages
* when the post requires a PMPro membership level.
*/
function my_pmpro_premium_badge_on_title( $title, $post_id = null ) {
if ( is_singular() || is_admin() ) {
return $title;
}
@andrewlimaza
andrewlimaza / pmpro-approvals-email-approve-deny.php
Last active June 11, 2026 12:45
PMPro Approvals, add an approve/deny link to one click action the pending member from email.
<?php
/**
* Creates {{approve_action_link}} and {{deny_action_link}} for pending emails.
* Only add it to the pending approval (admin) email template.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
/**
* Build the frontend URL for an email-based approval or denial action.
*
@andrewlimaza
andrewlimaza / redirect-missing-avatar-buddyboss-pmpro.php
Created June 10, 2026 14:08
Redirect BuddyBoss Users to "Update Avatar" when this is missing. Allows PMPro pages access for checkout/cancellation etc.
<?php
/**
* Redirect logged-in users with no BuddyBoss/BuddyPress avatar to the
* membership account page so they can upload a profile photo.
*/
function my_redirect_missing_avatar_to_account() {
if ( is_admin() || wp_doing_ajax() || wp_doing_cron() ) {
return;
}
@andrewlimaza
andrewlimaza / hide-pmpro-print-member-card.php
Created June 1, 2026 09:02
Remove the "View and Print Membership Card" Link in the Membership Account Page
<?php
/**
* Remove the View and Print Membership Card Link from the Membership Account page.
* To add this code to your site, please visit - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_hide_membership_card_link() {
remove_action( 'pmpro_member_links_top', 'pmpro_membership_card_member_links_top' );
}
add_action( 'init', 'my_pmpro_hide_membership_card_link' );
@andrewlimaza
andrewlimaza / pmpro-group-accounts-upgrade-seat-count.php
Last active May 29, 2026 10:50
PMPro Group Account Upgrade/Downgrade Seats Proration
<?php
/**
* For existing group parents, show current seat count and pre-fill the seats field.
* Runs before the group-accounts plugin's own pmpro_checkout_boxes hook (priority 10).
*/
function my_pmpro_group_parent_existing_seats_notice() {
if ( ! function_exists( 'pmprogroupacct_get_settings_for_level' ) || ! class_exists( 'PMProGroupAcct_Group' ) ) {
return;
}
@andrewlimaza
andrewlimaza / hide-pmpro-change-on-account-page.php
Created May 29, 2026 08:07
HIde "Change" option on the PMPro Membership Account Page
<?php
/**
* Hide the "Change" link on the Membership Account page for every active member.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_member_action_links( $pmpro_member_action_links, $level_id ) {
// Unset the 'change' action link entirely
if ( isset( $pmpro_member_action_links['change'] ) ) {
unset( $pmpro_member_action_links['change'] );
}
@andrewlimaza
andrewlimaza / sync-custom-avatars-with-bp.php
Created May 22, 2026 12:38
Sync Custom Avatars with BuddyPress
<?php
/**
* Sync WordPress avatar into BuddyPress, with reliable size enforcement.
*
* @param string $avatar <img> tag or raw URL BP would return.
* @param array $params Params passed to bp_core_fetch_avatar().
* @return string
*/
function my_pmpro_bp_sync_wordpress_avatar( $avatar, $params ) {
if ( empty( $params['object'] ) || 'user' !== $params['object'] ) {