Created
August 23, 2018 16:21
-
-
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.
This file contains hidden or 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 | |
/** | |
* 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' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This approach adds the Membership Account shortcode directly to the Dashboard Tab.
