Skip to content

Instantly share code, notes, and snippets.

View andrewlimaza's full-sized avatar

Andrew Lima andrewlimaza

View GitHub Profile
@andrewlimaza
andrewlimaza / remove-sub-delay-pmpro.php
Last active March 5, 2024 09:14
Remove Subscription Delay for members and past members and set the initial price to the billing amount.
<?php
/**
* Remove the Subscription Delay for members and past members.
* This will change the price of the initial amount to the billing amount for past members.
* Tweak this code accordingly to your needs or hire a developer.
*
* To add this code to your site, please follow this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_one_time_sub_delay( $checkout_level ) {
@andrewlimaza
andrewlimaza / remove-custom-trial-for-members.php
Created March 4, 2024 14:50
Remove custom trial for levels for existing and past members Paid Memberships Pro (Trial only used once)
<?php
/**
* Removes custom trial for active and past members.
* Adjust this code accordingly to price your membership level when removing the trial.
* To add this code to your site, please follow this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_remove_custom_trial( $level ) {
if ( is_admin() || ! is_user_logged_in() ) {
return $level;
@andrewlimaza
andrewlimaza / add-order-payment-details-to-pmpro-pdf.php
Created February 15, 2024 19:05
Paid Memberships Pro PDF Invoices Plugin - Show card digits, expiration and order status.
<?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_card_details( $data_array, $user, $order_data ) {
$data_array['{{card}}'] = esc_html( $order_data->accountnumber );
$data_array['{{card_expiration}}'] = esc_html( $order_data->expirationmonth . '/' . $order_data->expirationyear );
$data_array['{{order_status}}'] = esc_html( $order_data->status );
return $data_array;
@andrewlimaza
andrewlimaza / pmpro-network-subsite-dont-redirect.php
Created January 10, 2024 13:43
Stop the Multisite Membership Add On from redirecting to the main site on the network
<?php
/**
* This stops the logic of redirecting members to the main site on the network when viewing a PMPro page on the subsite.
* This is useful for cases where you need to still access these membership pages on the subsite.
*
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
remove_filter( 'pmpro_url', 'pmpro_multisite_pmpro_url', 10, 4 );
remove_action( 'init', 'pmpro_multisite_get_parent_site_pages', 20 );
@andrewlimaza
andrewlimaza / pmpro-kosovo-country.php
Last active January 4, 2024 12:19
Add Kosovo as country to Paid Memberships Pro
<?php
/**
* Add Kosovo as a country to the Paid Memberships Pro countries dropdown.
* 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_kosovo_country( $countries ) {
$countries['XK'] = 'Kosovo';
asort( $countries ); // Sort it alphabetically again.
return $countries;
}
@andrewlimaza
andrewlimaza / my-pmpro-cycle-period-reword-member-shortcode.php
Created January 2, 2024 07:47
Reword cycle period output from the pmpro_member shortcode to read better.
<?php
/**
* Change "Month" to "Monthly" etc when using `[pmpro_member field="membership_cycle_period"]` shortcode.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_reword_cycle_period_member_shortcode( $r, $user_id, $field ) {
// This isn't the cycle period field, let's bail.
if ( $field !== 'cycle_period' ) {
return $r;
@andrewlimaza
andrewlimaza / show-content-for-specific-course-pmpro.php
Created January 2, 2024 07:04
[my_pmpro_show_course_content] shortcode to show lesson content for a particular course ID.
<?php
/**
* Show lesson content for a specific course ID using a shortcode.
* Use [my_pmpro_show_course_content id="5"] to display the lessons for course ID of 5.
* Tweak this output to your needs further, as this is used as a starting template.
*
* To add this code to your site, please follow this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_show_course_content( $atts ) {
@andrewlimaza
andrewlimaza / next-payment-date-pmpro-shortcode.php
Created December 27, 2023 08:05
Next Payment Date PMPro Shortcode
<?php
/**
* Show the next payment date via shortcode [pmpro_next_payment_shortcode]
* Add this code to your site by following - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function pmpro_next_payment_shortcode() {
$next_payment = pmpro_next_payment();
if ( $next_payment ) {
$output = date_i18n( get_option( 'date_format' ), $next_payment );
@andrewlimaza
andrewlimaza / pmpro-orders-table-custom-columns.php
Created December 4, 2023 07:48
Custom order column for Paid Memberships Pro (New hooks).
<?php
/**
* Create a custom order column header and value for the PMPro Orders table.
* Add this code to your site by following - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
// Create a custom column in the orders table of PMPro.
function my_pmpro_add_column_header_order( $columns ) {
$columns['my_custom_column'] = __( 'My Custom Column', 'pmpro' );
return $columns;
@andrewlimaza
andrewlimaza / pmpro-pdf-invoices-discount-codes.php
Created December 1, 2023 14:45
Add {{discount_code}} to Paid Memberships Pro PDF Invoices
<?php
/**
* Add the variable {{discount_code}} to the PDF to show what discount code was used for the order.
* Follow this guide to add this custom code to your site - https://yoohooplugins.com/customize-wordpress/
*/
function my_pmpro_add_discount_code_to_pdf( $variables, $user, $order_data ) {
// Get the discount code used for the order and assign it to {{discount_code}}
$order = new MemberOrder( $order_data->code );
$discount_code = $order->getDiscountCode();