Avoid showing sales banner to user without the proper role#2339
Conversation
WalkthroughA permission check was introduced at the beginning of the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant FrmSalesApi
User->>FrmSalesApi: maybe_show_banner()
FrmSalesApi->>FrmSalesApi: Check 'frm_change_settings' capability
alt User has capability
FrmSalesApi->>FrmSalesApi: Continue banner logic
else User lacks capability
FrmSalesApi-->>User: Return false
end
Possibly related PRs
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (3)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
classes/models/FrmSalesApi.php (1)
251-253: Good addition of permission check to restrict banner visibility.Adding this check ensures that only users with the capability to change settings will see the sales banner, which aligns with the PR objective. This prevents displaying the banner to users who cannot take any action on the sale.
I do notice that
current_user_can()is used directly here, whileFrmAppHelper::permission_check()is used in thedismiss_banner()method (line 355). Both approaches work, but for consistency, consider using the same pattern across the codebase.- if ( ! current_user_can( 'frm_change_settings' ) ) { + if ( ! FrmAppHelper::current_user_can( 'frm_change_settings' ) ) {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
classes/models/FrmSalesApi.php(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
classes/models/FrmSalesApi.php (1)
classes/helpers/FrmAppHelper.php (1)
current_user_can(2052-2074)
⏰ Context from checks skipped due to timeout of 90000ms (6)
- GitHub Check: Cypress
- GitHub Check: PHP 7.4 tests in WP trunk
- GitHub Check: PHP 8 tests in WP trunk
- GitHub Check: PHP 8 tests in WP trunk
- GitHub Check: PHP 7.4 tests in WP trunk
- GitHub Check: Cypress
This is to prevent it from appearing for users who can't really act on the sale.