Skip to:
Content

bbPress.org


Ignore:
Timestamp:
10/09/2012 06:52:38 PM (12 years ago)
Author:
johnjamesjacoby
Message:

Capabilities:

  • Introduce sub-action for saving a users profile.
  • Hook capability saving functions to this new action.
  • Remove duplicate admin routine from /bbp-admin/bbp-users.php.
  • Remove hardcoded capability saving from bbp_edit_user_handler().
  • Add edit_user capability checks to cap save and reset functions.
  • Fixes bug when caps would be lost when a user saves their own profile.
  • Fixes #1963.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bbp-includes/bbp-core-caps.php

    r4222 r4236  
    875875        return false;
    876876
    877     // Bail if not a member of this blog
    878     if ( ! user_can( $user_id, 'read' ) )
     877    // Bail if current user cannot edit this user
     878    if ( ! current_user_can( 'edit_user', $user_id ) )
    879879        return false;
    880880
     
    914914        return false;
    915915
    916     // Bail if not a member of this blog
    917     if ( ! user_can( $user_id, 'read' ) )
     916    // Bail if current user cannot edit this user
     917    if ( ! current_user_can( 'edit_user', $user_id ) )
    918918        return false;
    919919
     
    938938    // Success
    939939    return true;
     940}
     941
     942/**
     943 * Helper function hooked to 'bbp_edit_user_profile_update' action to save or update
     944 * user roles and capabilities.
     945 *
     946 * @since bbPress (r4235)
     947 *
     948 * @param int $user_id
     949 * @uses bbp_reset_user_caps() to reset caps
     950 * @usse bbp_save_user_caps() to save caps
     951 */
     952function bbp_edit_user_profile_update_capabilities( $user_id = 0 ) {
     953
     954    // Bail if no user ID was passed
     955    if ( empty( $user_id ) )
     956        return;
     957
     958    // Either reset caps for role
     959    if ( ! empty( $_POST['bbp-default-caps'] ) ) {
     960        bbp_reset_user_caps( $user_id );
     961
     962    // Or set caps individually
     963    } else {
     964        bbp_save_user_caps( $user_id );
     965    }
    940966}
    941967
Note: See TracChangeset for help on using the changeset viewer.