Skip to content

Instantly share code, notes, and snippets.

View andrewlimaza's full-sized avatar

Andrew Lima andrewlimaza

View GitHub Profile
@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'] ) {
@andrewlimaza
andrewlimaza / adjust-pmpro-subscription-delay.php
Created May 21, 2026 07:32
Adjust Subscription Delay based on signup date
<?php
/**
* Set the subscription profile_start_date to the 1st of a month next year based on signup day.
* Days 1–14: 1st of the current month, next year.
* Days 15+: 1st of the following month, next year.
*
* NOTE: This is for yearly membership levels.
*/
function my_pmpro_set_annual_profile_start_date( $checkout_level ) {
if ( ! pmpro_isLevelRecurring( $checkout_level ) ) {
@andrewlimaza
andrewlimaza / apply-discount-code-to-child-levels.php
Created May 11, 2026 11:40 — forked from MaximilianoRicoTabo/apply-discount-code-to-child-levels.php
Apply a discount code to child level at the moment of checkout
<?php
/**
* Apply a discount code to child level at the moment of checkout
*
* link: TBD
*
* 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/
@andrewlimaza
andrewlimaza / pmpro-recurring-level-sub-delay-example.php
Created April 29, 2026 13:48
Set billing start date (subscription delay) to expiration date when member is renewing for recurring level
<?php
/**
* Move the members subscription start date based on their remaining days of current level that has an expiration date.
* Note: Do not set initial payment to $0, let members pay ahead for their next billing period before starting subscriptions.
* Useful for any migration where we cannot migrate the subscription and need to checkout again.
*/
function my_pmpro_renewal_defer_startdate( $checkout_level ) {
// Only run on the frontend during checkout
if ( ! function_exists( 'pmpro_getMembershipLevelForUser' ) ) {
return $checkout_level;
@andrewlimaza
andrewlimaza / pmpro-update-webhook-id-paypal.php
Created April 17, 2026 13:48
PMPro update PayPal Webhook ID value for the new PayPal gateway.
<?php
/**
* Adjust the PMPro PayPal gateway webhook ID to point to a new webhook that was manually created.
* Run this in your browser once yoursite.com/wp-admin/?pp_webhook_id=12345
* Delete this snippet when no longer needed.
*
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
add_action( 'admin_init', function() {
if ( ! isset( $_GET['pp_webhook_id'] ) ) {
@andrewlimaza
andrewlimaza / override-set-expiration-date-pmpro.php
Last active April 15, 2026 11:25
Override Set Expiration Date logic to push out the expiration date based on time of checkout
<?php
/**
* Manually overrides the YYYY-MM-DD settings of a set expiration date level.
* If the checkout is 15-30 July of the current year, push it out by another year.
* The example expiration date is 31 July of current year in the Set Expiration Date Add On.
*
* Tweak all the code accordingly for your needs, and add level ID checks for multiple level compatibility.
* To add this code to your site you may follow this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_override_sed_date( $date ) {
@andrewlimaza
andrewlimaza / allow-gateway-swop-query-param.php
Last active April 21, 2026 15:57
Allow query parameter &gateway=xxxx for multiple gateway options at checkout PMPro.
<?php
/**
* Allows you to hotswap gateway logic at checkout via query parameter.
* Helpful if the gateway doesn't have native gateway swapping capabilities.
* Add &gateway=paypal (for example) to your checkout URL to load the new PayPal payment gateway.
*
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
add_filter( 'pmpro_valid_gateways', function( $gateways ) {
$gateways[] = 'paypal'; //Change paypal to any other gateway you have installed/configured.