Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/25/2015 07:32:22 PM (9 years ago)
Author:
r-a-y
Message:

Caps: Fix issue with passing an empty array as an argument in bp_current_user_can().

Changes to bp_current_user_can() in #6501 broke older capability checks
relying on an empty argument to be passed in order to use a fallback value.

Most notably, bp_current_user_can('bp_xprofile_change_field_visibility' )
checks now passed by default. This resulted in the "Change" link to
always be visible when editing a profile field even if an admin has enabled
"Enforce field visibility" for that particular field.

This commit fixes this issue by passing a null value if there are no
extra arguments to pass in bp_current_user_can(). Commit also includes
a unit test.

See #6730 (trunk).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-caps.php

    r10356 r10377  
    289289    }
    290290
     291    // Backward compatibility for older bp_current_user_can() checks
     292    if ( empty( $args ) ) {
     293        $args = null;
     294    }
     295
    291296    // Use root blog if no ID passed.
    292297    if ( empty( $blog_id ) ) {
Note: See TracChangeset for help on using the changeset viewer.