Skip to content

Instantly share code, notes, and snippets.

View andrewlimaza's full-sized avatar

Andrew Lima andrewlimaza

View GitHub Profile
@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' );
@andrewlimaza
andrewlimaza / show-order-status-pmpro-pdf.php
Created December 11, 2024 05:44
Show order/invoice status in PMPro PDF
<?php
/**
* Add custom variables to PDF template editor to show some more order information.
* To add this code to your site, please visit - https://yoohooplugins.com/customize-wordpress/
*/
function my_pmpro_pdf_status_details( $data_array, $user, $order_data ) {
$data_array['{{order_status}}'] = esc_html( $order_data->status );
return $data_array;
}
add_filter( 'pmpro_pdf_invoice_custom_variables', 'my_pmpro_pdf_status_details', 10, 3 );
@andrewlimaza
andrewlimaza / move-pmpro-content-higher.php
Created December 2, 2024 07:44
Move the content restricted message higher up the course content for LifterLMS
<?php
/**
* Move the Paid Memberships Pro content restricted message higher up in LifterLMS course content.
* This requires "Course Information" block to be on the page and shown before this using jQuery.
* Tweak this jQuery code to fit your needs and move the content higher up.
*
* To add the code to your site you may follow this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_move_pmpro_div_with_jquery_llms() {
?>
@andrewlimaza
andrewlimaza / filter-pmpro-login-url.php
Created November 28, 2024 13:11
Filter the PMPro Login URL for sites.
<?php
/**
* Adjust the login URL value that PMPro uses and override it to use a custom one.
* Use this to force the login URL even if the frontend URL page is set.
* You can tweak this further based on current page, condtionals and more. This is a starting point.
* To add this code to your site follow this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_login_url( $login_url, $redirect, $reauth ) {
$login_url = '/login'; // Change the slug of this.
@andrewlimaza
andrewlimaza / pmpro-flat-tax-rate-all-orders.php
Created November 28, 2024 07:18
Flat rate 15% VAT/TAX added to all PMPro orders and checkouts
<?php
/**
* Add 15% tax to all PMPro checkouts.
* Add this code to your site by visiting this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function customtax_pmpro_tax( $tax, $values, $order ) {
$tax = round((float)$values['price'] * 0.15, 2);
return $tax;
}
add_filter("pmpro_tax", "customtax_pmpro_tax", 10, 3);
@andrewlimaza
andrewlimaza / ccbill-sub-account-pmpro-checkout.php
Created November 22, 2024 08:09
Adjust CCBill Sub Account for Paid Memberships Pro Checkouts
<?php
/**
* Change the CCBill Sub Account for AddOn Package purchase.
* This can be tweaked further to change the subaccount (or any other argument) based on custom conditionals.
*
* REQUIRES PMPRO CCBILL 0.6+
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_ccbill_change_sub_account( $ccbill_args, $order ) {
// Let's replace the subaccount when we get AddOn Package purchase.
@andrewlimaza
andrewlimaza / remove-email-validation-on-certain-pages.php
Created November 6, 2024 06:52
Remove Email Validation checks on Edit Member and Frontend Edit Profile page to allow updating of User Fields.
<?php
/**
* Removes the email validation checks on the Edit Member and Frontend Edit Profile pages.
* This allows pending validation members to edit their own User Fields.
* This is only needed if the "Restrict Fields For Membership Levels" option is selected.
*
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_email_bypass_validation_frontend() {
global $pmpro_pages;