What You’ll Learn
- Understanding why raw PHP conditions don’t work in templates
- Using Pro Reports filter hooks for conditional output
- Creating custom placeholder tokens
- Building conditional messages based on data values
Extension Add-on - This add-on provides standalone functionality within MainWP Dashboard. No third-party plugins required.
mainwp_pro_reports_parsed_section_tokensmainwp_pro_reports_parsed_other_tokens
Usemainwp_pro_reports_parsed_section_tokenswhen your condition depends on section rows, andmainwp_pro_reports_parsed_other_tokenswhen you want to update non-section tokens or set a custom placeholder token. Keep the expectedsections_dataandother_tokens_datastructure intact, but you can add or update token keys inside the relevantbodyorheaderarray.
[plugin.updated.count]), remember those must be placed outside section tags in the template.
A full token reference is here: Available Pro Reports Tokens
How to use it
- In your report template, insert a custom placeholder where the message should appear, e.g.
[my.custom.message]. For the example below, place that placeholder outside any section tags so Pro Reports treats it as an “other” token. - Add your code on the Dashboard, either in your Dashboard theme’s
functions.phpor in a PHP snippet through the Custom Dashboard extension. - In your filter, read the parsed token you care about (for example
[plugin.updated.count]) and set the value for your placeholder token. Keep the top-level parsed array structure intact and add or update the token key in the relevantbodyorheaderarray. - (General setup reminder) Pro Reports pulls activity from the free MainWP Child Reports plugin so new installs may need some time to record data.
Example: one message for 0, 1, or many updates
Goal- 0 → “No updates needed this month.”
- 1 → “We performed 1 update during this period.”
- ≥2 → “We performed X updates during this period.”
Place
[my.custom.message] where the text should appear, outside any section tags. If you also show a count like [plugin.updated.count], keep that outside any section token as well.
- The condition runs after Pro Reports has built the token array, so
[plugin.updated.count]is a real integer, not a placeholder string. - You preserve the expected parsed array shape and add the
[my.custom.message]token value insideother_tokens_data['body'], which Pro Reports later replaces in the template.
[plugin.updated.count] for the relevant token from the tokens list.
Related Resources
- Available Pro Reports Tokens - Complete token reference
- Create Custom Report Templates - Build custom PHP templates
- Pro Reports Extension - Main Pro Reports documentation