Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include super admins to the users list in Exclude settings #835

Merged
merged 5 commits into from Mar 18, 2016

Conversation

Projects
None yet
3 participants
@marcin-lawrowski
Copy link
Contributor

commented Mar 15, 2016

Fixes #829

It's a work in progress

$super_admins = get_super_admins();
foreach ( $super_admins as $admin ) {
$user = get_user_by ( 'login', $admin );
$users_array[] = $user;

This comment has been minimized.

Copy link
@lukecarbis

lukecarbis Mar 15, 2016

Contributor

Should we check if the user already exists in the array first?

This comment has been minimized.

Copy link
@marcin-lawrowski

marcin-lawrowski Mar 16, 2016

Author Contributor

I choose to check for duplicates further in the foreach loop.

if ( array_key_exists( $user->ID, $users_added_to_response ) ) {
continue;
} else {
$users_added_to_response[$user->ID] = true;

This comment has been minimized.

Copy link
@lukecarbis

lukecarbis Mar 15, 2016

Contributor

Spacing around the variable inside the square brackets.

This comment has been minimized.

Copy link
@marcin-lawrowski

marcin-lawrowski Mar 16, 2016

Author Contributor

Fixed

@lukecarbis

This comment has been minimized.

Copy link
Contributor

commented Mar 17, 2016

@chacha I've made a few changes in f4a600d. Could you please review, and if you're happy, merge?

@@ -464,10 +464,14 @@ function( $user_id ) {
);
if ( is_multisite() && is_super_admin() ) {
$super_admins = get_super_admins();
foreach ( $super_admins as $admin ) {
$users[] = get_user_by( 'login', $admin );

This comment has been minimized.

Copy link
@lukecarbis

lukecarbis Mar 17, 2016

Contributor

This array is an array of Authors, not WP_Users. Hence the change.

},
get_super_admins()
);
$users = array_unique( array_merge( $users, $super_admins ) );

This comment has been minimized.

Copy link
@lukecarbis

lukecarbis Mar 17, 2016

Contributor

Array unique so we don't have duplicates if a Super Admin is also an Administrator for the site.

@chacha

This comment has been minimized.

Copy link
Contributor

commented Mar 18, 2016

Tested. Good Job @marcin-lawrowski! 👍

@chacha chacha merged commit f4a600d into develop Mar 18, 2016

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@lukecarbis lukecarbis deleted the bugfix/issue-829 branch Mar 18, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.