[buddypress-trac] [BuddyPress Trac] #7192: Improve $args included in `bp_current_user_can` and `bp_user_can` filters.

buddypress-trac noreply at wordpress.org
Wed Jul 20 17:33:05 UTC 2016


#7192: Improve $args included in `bp_current_user_can` and `bp_user_can` filters.
--------------------------+-----------------------------
 Reporter:  dcavins       |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Core          |    Version:
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 in `bp_current_user_can()` and `bp_user_can()`, the originally passed
 `$args` array gets overwritten for use with WordPress's functions like
 this:

 {{{
 $args = array( $blog_id, $capability, $args );
 $retval = call_user_func_array( 'current_user_can_for_blog', $args );
 }}}

 Then, when they're included in the final filter, this compounded version
 is used. So, in ``bp_current_user_can()`, the filter parameters are
 actually:
 `apply_filters( 'bp_current_user_can', $retval, $capability, $blog_id,
 array( $blog_id, $capability, $args ) )`

 Similarly, in `bp_user_can()`, the filter parameters are actually:
 `apply_filters( 'bp_user_can', $retval, $user_id, $capability, $site_id,
 array( $user_id, $capability, $args ) )`

 I'd like pass the original `$args` array back out for easy manipulation by
 plugins. (And the other elements in the compounded array are duplicated in
 the filter parameters, so don't add value.)

 My patch removes the modification of the `$args` variable in the course of
 each function, so that the original `$args` variables are passed out as
 they were passed in.

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/7192>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list