WordPress.org

Making WordPress.org

Opened 9 months ago

Closed 6 months ago

Last modified 3 months ago

#2590 closed defect (fixed)

Enhance compatibility with per forum moderators

Reported by: ocean90 Owned by: ocean90
Milestone: Priority: normal
Component: Support Forums Keywords: has-patch commit
Cc:

Description

bbPress 2.6 supports per forum moderators. This is handled in bbp_map_primary_meta_caps(). But the additional checks are not done if no post ID is passed to the WP_User::has_cap() check.

  • In Topic_Resolution\Plugin::user_can_resolve() we can use the existing $topic_id variable.
  • In User_Badges\Plugin::is_user_moderator() using get_queried_object_id() seems to work.
  • Also affected: Stickies_Compat and user flagging in User_Moderation.

Noticed this while checking how this actually works because @danielbachhuber requested this.

Attachments (3)

2590.diff (1.4 KB) - added by ocean90 9 months ago.
2590.2.diff (6.2 KB) - added by SergeyBiryukov 9 months ago.
2590.3.diff (2.1 KB) - added by SergeyBiryukov 8 months ago.

Download all attachments as: .zip

Change History (13)

@ocean90
9 months ago

#1 @SergeyBiryukov
9 months ago

  • Keywords has-patch added

In User_Badges\Plugin::is_user_moderator() using get_queried_object_id() seems to work.

It doesn't in moderator views, e.g. 'Archived'. get_the_ID() works though.

On a related note, bbp_get_reply_author_id() should be replaced with get_post_field( 'post_author' ) there, since the function runs for both topics and replies. bbp_get_reply_author_id() falls back to the same line for topics (with $reply_id = 0), so this seems more straightforward.

Also affected: Stickies_Compat and user flagging in User_Moderation.

2590.2.diff handles some more affected instances in Moderators class and wporg-support theme.

Not sure about user flagging though, I think only global moderators should be able to flag users.

Note: The change in wporg_support_add_moderation_notice() (wporg-support/functions.php) is unnecessary at the moment, since per-forum moderators never see that notice:

The latter two points seem worth fixing though, so I kept that change in the patch, but I guess it can be committed separately later.

Last edited 9 months ago by SergeyBiryukov (previous) (diff)

This ticket was mentioned in Slack in #forums by ocean90. View the logs.


9 months ago

#3 @macmanx
9 months ago

Yes, it would be best if actions that had a global effect, like flagging, were limited to global moderators. Thanks!

#4 @SergeyBiryukov
8 months ago

In 5294:

Support Forums: Use post-specific moderate capability checks in Moderators::archive_handler() and ::get_archive_link().

See #2590.

#5 @SergeyBiryukov
8 months ago

In 5295:

Support Forums: Support Forums: Use post-specific moderate capability check in Stickies_Compat::user_can_stick().

See #2590.

#6 @SergeyBiryukov
8 months ago

In 5296:

Support Theme: Use post-specific moderate capability checks in wporg_support_add_moderation_notice() and bbpress/form-topic.php.

See #2590.

#7 @SergeyBiryukov
8 months ago

  • Keywords commit added

Committed everything I could, refreshed the rest in 2590.3.diff.

#8 @SergeyBiryukov
7 months ago

@ocean90: Anything I can do to help move 2590.3.diff forward?

#9 @ocean90
6 months ago

  • Owner set to ocean90
  • Resolution set to fixed
  • Status changed from new to closed

In 5523:

Support Forums: Pass post IDs to moderate capability checks.

Props SergeyBiryukov.
Fixes #2590.

This ticket was mentioned in Slack in #meta by sergey. View the logs.


3 months ago

Note: See TracTickets for help on using tickets.