Making WordPress.org

Changeset 12802


Ignore:
Timestamp:
08/03/2023 02:13:10 AM (17 months ago)
Author:
dd32
Message:

Support Forums: Use a dedicated meta_key for the post-as-moderator functionality to avoid other moderation actions overwriting the value.

See #6839.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-moderators.php

    r12795 r12802  
    55class Moderators {
    66
    7     const ARCHIVED       = 'archived';
    8     const ARCHIVED_META  = '_wporg_bbp_unarchived_post_status';
    9     const MODERATOR_META = '_wporg_bbp_moderator';
    10     const DEFAULT_STATUS = 'publish';
    11     const VIEWS          = array( 'archived', 'pending', 'spam' );
     7    const ARCHIVED               = 'archived';
     8    const ARCHIVED_META          = '_wporg_bbp_unarchived_post_status';
     9    const MODERATOR_META         = '_wporg_bbp_moderator';
     10    const MODERATOR_REPLY_AUTHOR = '_wporg_bbp_moderator_reply_author';
     11    const DEFAULT_STATUS         = 'publish';
     12    const VIEWS                  = array( 'archived', 'pending', 'spam' );
    1213
    1314    public function __construct() {
     
    11581159        // Record the real user in the post meta.
    11591160        $post_data['meta_input'] ??= [];
    1160         $post_data['meta_input'][ self::MODERATOR_META ] = get_current_user_id();
     1161        $post_data['meta_input'][ self::MODERATOR_REPLY_AUTHOR ] = get_current_user_id();
    11611162
    11621163        return $post_data;
     
    11761177        }
    11771178
    1178         $user = get_user_by( 'id', get_post_meta( bbp_get_reply_id(), self::MODERATOR_META, true ) );
     1179        $user = get_user_by( 'id', get_post_meta( bbp_get_reply_id(), self::MODERATOR_REPLY_AUTHOR, true ) );
    11791180
    11801181        printf(
     
    11871188    /**
    11881189     * Pretend the @moderator user can moderate, except when they're logged in.
     1190     *
     1191     * This keeps the moderator account as a low-access account, while also showing the replies
     1192     * with a moderator badge. This should probably ideally be a filter on the badges.
    11891193     */
    11901194    public function anon_moderator_user_has_cap( $allcaps, $caps, $args, $user ) {
Note: See TracChangeset for help on using the changeset viewer.