[buddypress-trac] [BuddyPress] #5177: Add filter to permit access to group edition and deletion to other than super_admin

buddypress-trac noreply at wordpress.org
Tue Sep 17 18:21:15 UTC 2013


#5177: Add filter to permit access to group edition and deletion to other than
super_admin
--------------------------+-----------------------------
 Reporter:  asakurayoh    |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Groups        |    Version:  1.8.1
 Severity:  major         |   Keywords:
--------------------------+-----------------------------
 Hi.

 I got this problem where my buddypress is in a multi-site environment. If
 an admin of a site want to edit or delete a buddypress group, it is not
 possible, because the access is limited to the super admin only. In bp-
 groups/bp-groups-admin.php, there are those lines (one in
 bp_groups_admin_edit and on ine bp_groups_admin_delete):
 {{{
 if ( ! is_super_admin() )
   die( '-1' );
 }}}


 I propose to change it to this:
 {{{
 $as_access_rights = apply_filters('bp_groups_admin_edit_access_rights',
 is_super_admin());
 if ( ! $as_access_rights )
     die( '-1' );
 }}}
 and:
 {{{
 $as_access_rights = apply_filters('bp_groups_admin_delete_access_rights',
 is_super_admin());
 if ( ! $as_access_rights )
     die( '-1' );
 }}}


 So with that, we can extend the fonctionnality without breaking the
 previous behaviour.

 That help me to add the "administrator" role of wordpress to access those
 pages. Ex:


 {{{
 add_filter( 'bp_groups_admin_edit_access_rights',
 'wp_flexi_bp_groups_admin_access_rights', 10, 1 );
 add_filter( 'bp_groups_admin_delete_access_rights',
 'wp_flexi_bp_groups_admin_access_rights', 10, 1 );

 function wp_flexi_bp_groups_admin_access_rights($is_super_admin){
   $current_user = wp_get_current_user();
   if ( empty( $current_user ) ){
     return false;
   }
   if($is_super_admin || in_array( 'administrator', (array)
 $current_user->roles )){
     return true;
   }
   return false;
 }
 }}}


 I think it's important to be flexible ;)

 Thanks

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


More information about the buddypress-trac mailing list