Skip to:
Content

bbPress.org

Changeset 6575


Ignore:
Timestamp:
06/16/2017 09:37:25 PM (7 years ago)
Author:
johnjamesjacoby
Message:

Super Moderators: prefer edit_user with an ID over edit_users without one.

This change makes sure we know exactly which user ID the user is trying to edit. In cases where there is no ID available, we'll try to guess at the displayed user ID, and if that's empty too, we'll do nothing.

This allows the "User Role" template part to load properly for Super Moderators.

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/users/capabilities.php

    r6574 r6575  
    120120            if ( bbp_allow_super_mods() ) {
    121121
     122                // Get the user ID
     123                $_user_id = ! empty( $args[0] )
     124                    ? (int) $args[0]
     125                    : bbp_get_displayed_user_id();
     126
    122127                // Users can always edit themselves, so only map for others
    123                 if ( ! empty( $args[0] ) && ( $args[0] !== $user_id ) ) {
     128                if ( ! empty( $_user_id ) && ( $_user_id !== $user_id ) ) {
    124129
    125130                    // Super moderators cannot edit keymasters
    126                     if ( ! bbp_is_user_keymaster( $args[0] ) ) {
     131                    if ( ! bbp_is_user_keymaster( $_user_id ) ) {
    127132                        $caps = array( 'moderate' );
    128133                    }
  • trunk/src/templates/default/bbpress/form-user-edit.php

    r6558 r6575  
    127127    </fieldset>
    128128
    129     <?php if ( current_user_can( 'edit_users' ) && ! bbp_is_user_home_edit() ) : ?>
     129    <?php if ( ! bbp_is_user_home_edit() && current_user_can( 'edit_user', bbp_get_displayed_user_id() ) ) : ?>
    130130
    131131        <h2 class="entry-title"><?php esc_html_e( 'User Role', 'bbpress' ) ?></h2>
  • trunk/src/templates/default/bbpress/user-subscriptions.php

    r6258 r6575  
    1515<?php if ( bbp_is_subscriptions_active() ) : ?>
    1616
    17     <?php if ( bbp_is_user_home() || current_user_can( 'edit_users' ) ) : ?>
     17    <?php if ( bbp_is_user_home() || current_user_can( 'edit_user', bbp_get_displayed_user_id() ) ) : ?>
    1818
    1919        <div id="bbp-user-subscriptions" class="bbp-user-subscriptions">
Note: See TracChangeset for help on using the changeset viewer.