[wp-trac] [WordPress Trac] #41101: Add filter to prevent the addition of a user to a blog

WordPress Trac noreply at wordpress.org
Thu Aug 3 21:11:42 UTC 2017


#41101: Add filter to prevent the addition of a user to a blog
---------------------------------------------+------------------------
 Reporter:  jmdodd                           |       Owner:  flixos90
     Type:  enhancement                      |      Status:  reviewing
 Priority:  normal                           |   Milestone:  4.9
Component:  Users                            |     Version:  trunk
 Severity:  normal                           |  Resolution:
 Keywords:  has-patch has-unit-tests commit  |     Focuses:  multisite
---------------------------------------------+------------------------
Changes (by flixos90):

 * keywords:  has-patch has-unit-tests needs-testing => has-patch has-unit-
     tests commit


Comment:

 Thanks for working on this @jmdodd. The patch works well, I tested it
 thoroughly. There are only a few things I tweaked in
 [attachment:41101.3.diff] - most of them minor, though particularly the
 user-facing messages needed a few adjustments (due to some terrible WP
 Admin code that was there before):

 * Ensure that the error message when adding an existing user to a site (in
 `wp-admin/user-new.php`) shows with the error color (red) instead of
 success color (green). This was actually wrong for a few other existing
 messages as well, so I adjusted this too.
 * Correctly handle the case where a new user is being created that cannot
 be added to the site though (in `wp-admin/user-new.php`). This was a bit
 tricky since there is no way to detect whether `add_user_to_blog()` fails
 from `wpmu_activate_signup()`. I added a check `is_user_member_of_blog()`
 afterwards to detect possible errors. It's hacky, but probably the best we
 can do at this point. A message "User has been created, but could not be
 added to this site." is shown under these circumstances.
 * Use the correct term "site" instead of "blog" in the default error
 message in `add_user_to_blog()`.
 * Remove the statements to delete temporary sites and users from the
 tests, since that happens automatically as these SQL queries are not
 committed.
 * Add `4.9` to the new filter doc block.
 * Minor changes in the new filter documentation.
 * Minor code style tweaks to make the code better readable, particularly
 when using `is_wp_error()` around function calls.

 Let's get this merged!

--
Ticket URL: <https://core.trac.wordpress.org/ticket/41101#comment:10>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list