Forked from strangerstudios/my_pmpro_reports_extras
Last active
April 16, 2021 01:23
-
-
Save kimcoleman/f028ca0d25fed6690ed238da8f5909da to your computer and use it in GitHub Desktop.
Add a Custom Report to the Memberships > Reports Screen in 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 | |
/** | |
* Add a Custom Report to the Memberships > Reports Screen in Paid Memberships Pro. | |
* | |
* For each report, add a line like: | |
* global $pmpro_reports; | |
* $pmpro_reports['slug'] = 'Title'; | |
* | |
* For each report, also write two functions: | |
* pmpro_report_{slug}_widget() to show up on the report homepage. | |
* pmpro_report_{slug}_page() to show up when users click on the report page widget. | |
* | |
*/ | |
global $pmpro_reports; | |
$pmpro_reports['sample'] = __('My Sample Report', 'pmpro-reports-extras'); | |
// Sample Report for Metabox | |
function pmpro_report_sample_widget() { ?> | |
<span id="pmpro_report_sample" class="pmpro_report-holder"> | |
<p>Hi! I'm a sample report!</p> | |
<?php if ( function_exists( 'pmpro_report_sample_page' ) ) { ?> | |
<p class="pmpro_report-button"> | |
<a class="button button-primary" href="<?php echo admin_url( 'admin.php?page=pmpro-reports&report=sample' ); ?>"><?php _e('Details', 'paid-memberships-pro' );?></a> | |
</p> | |
<?php } ?> | |
</span> | |
<?php | |
} | |
// Sample Report for Individual Report Page | |
function pmpro_report_sample_page() { ?> | |
<h1><?php _e( 'This is a Sample', 'pmpro-reports-extras' ); ?></h2> | |
<p>This report demonstrates how to add a custom report to PMPro. Enjoy!.</p> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This recipe is included in the blog post on "Create Custom Reports for the Memberships > Reports Admin" at Paid Memberships Pro here: https://www.paidmembershipspro.com/create-custom-reports-for-the-memberships-reports-admin/