Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kimcoleman/f028ca0d25fed6690ed238da8f5909da to your computer and use it in GitHub Desktop.
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.
<?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
}
@laurenhagan0306
Copy link

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/

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