Skip to content
This repository has been archived by the owner on Sep 27, 2022. It is now read-only.

Commit

Permalink
Make sure the "custom" cap group is always added last.
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Tadlock committed Oct 1, 2015
1 parent 69807e1 commit c3c84fb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
15 changes: 14 additions & 1 deletion admin/functions-cap-groups.php
Expand Up @@ -213,7 +213,7 @@ function members_register_cap_groups() {
if ( members_cap_group_exists( 'all' ) ) {

// Set up an empty caps array and get the `all` group object.
$caps = array();
$caps = array();
$_group = members_get_cap_group( 'all' );

// Get the caps from every registered group.
Expand All @@ -226,6 +226,19 @@ function members_register_cap_groups() {
// Assign all caps to the `all` group.
$_group->caps = array_unique( $caps );
}

// Check if the `custom` group is registered and there's possibly other non-default groups.
if ( has_action( 'members_register_cap_groups' ) && members_cap_group_exists( 'custom' ) ) {

// Get the custom group object.
$custom = members_cap_group_factory()->groups[ 'custom' ];

// Unset the custom group object.
unset( members_cap_group_factory()->groups[ 'custom' ] );

// Move the custom group object to the end.
members_cap_group_factory()->groups[ 'custom' ] = $custom;
}
}

/**
Expand Down
3 changes: 2 additions & 1 deletion changelog.md
@@ -1,6 +1,6 @@
# Change Log

## [1.0.3] - 2015-9-28
## [1.0.3] - 2015-10-01

### Added

Expand All @@ -13,6 +13,7 @@
* Make sure custom caps (post types, taxonomies, etc.) that aren't stored get saved when editing a role.
* Make sure the "All" capability group actually lists all caps from all groups.
* Use the `$user` variable instead of `$author` variable in `members_list_users()`.
* "Custom" cap group should always be added last.

## [1.0.2] - 2015-09-15

Expand Down

0 comments on commit c3c84fb

Please sign in to comment.