Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kimcoleman/bcd70fa56089dbcb2bda17899a90940d to your computer and use it in GitHub Desktop.
Save kimcoleman/bcd70fa56089dbcb2bda17899a90940d to your computer and use it in GitHub Desktop.
Show the pmpro_account shortcode on the WooCommmerce My Account page for members who have a history of membership through Paid Memberships Pro.
<?php
/**
* Show the pmpro_account shortcode on the WooCommmerce My Account page for members
* who have a history of membership through Paid Memberships Pro.
*/
function pmpro_do_membership_account_shortcode() {
global $wpdb, $current_user;
if( is_user_logged_in() && defined( 'PMPRO_VERSION' ) ) { ?>
<style> .pmpro_actionlinks {display: none; } </style>
<?php
$invoices = $wpdb->get_results("SELECT *, UNIX_TIMESTAMP(timestamp) as timestamp FROM $wpdb->pmpro_membership_orders WHERE user_id = '$current_user->ID' AND status NOT IN('refunded', 'review', 'token', 'error') ORDER BY timestamp DESC LIMIT 6");
if( ! empty( $invoices ) ) {
echo do_shortcode( '[pmpro_account section="membership,invoices"]' );
}
}
}
add_action( 'woocommerce_after_my_account', 'pmpro_do_membership_account_shortcode' );
@kimwhite
Copy link

This approach adds the Membership Account shortcode directly to the Dashboard Tab.
Screenshot 2025-03-17 at 11 48 08 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment