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
Use them to read existing values and set your own token’s value. Do not change the structure or order of the arrays, only the values.
[plugin.updated.count]), remember those must be placed outside section tags in the template.
A full token reference is here: https://mainwp.com/kb/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]. (You’re just placing a token name; you’ll set its value via the filter.) - Add your code on the Dashboard, either in your Dashboard theme’s
functions.phpor via 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. Don’t alter array structure or token order. - (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. If you also show a count like [plugin.updated.count], keep that outside any section token.
- The condition runs after Pro Reports has built the token array, so
[plugin.updated.count]is a real integer, not a placeholder string. - You’re only changing token values, as required by the filter contract.
[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