Skip to content

Instantly share code, notes, and snippets.

@gausam
Last active April 11, 2024 13:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gausam/6847a236846e0af21b75e2ceae4a8088 to your computer and use it in GitHub Desktop.
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.
<?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