Last active
April 11, 2024 13:46
-
-
Save gausam/6847a236846e0af21b75e2ceae4a8088 to your computer and use it in GitHub Desktop.
Add a custom shortcode to display the payment type on a member's most recent order.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This recipe adds a custom shortcode ([mypmpro_payment_type]) custom shortcode | |
* to display the payment type on a member's most recent order. | |
* | |
* 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/ | |
*/ | |
function mypmpro_payment_type() { | |
$last_order = new MemberOrder(); | |
$last_order->getLastMemberOrder(); | |
if ( ! empty( $last_order ) ) { | |
return $last_order->payment_type; | |
} | |
return "N/A"; | |
} | |
add_shortcode( 'mypmpro_payment_type', 'mypmpro_payment_type' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment