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

WordPress Trac noreply at wordpress.org
Sat Jul 1 16:37:06 UTC 2017


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

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


Comment:

 @flixos90 looks like that is correct. See
 [https://core.trac.wordpress.org/browser/trunk/tests/phpunit/includes/testcase.php#L301].
 Not sure if we should always remove the hooks in the test function, or
 just rely on that function and avoid unneeded calls to `remove_action()`
 and `remove_filter()`.

 Looking at the most recent patch @jmdodd, the filter needs a PHPDocBlock.

 I did some testing, and found a few issues with how it works. To test, I
 used `add_filter( 'pre_add_user_to_blog', '__return_false', 10, 4 );`.

 Add Existing User Form
 - In the network site admin add user screen, the filter correctly prevents
 the user from being added. However, a success message is incorrectly
 displayed in the admin [attachment:Screen Shot 2017-07-01 at 12.20.19
 PM.png].
 - The add user screen in the site admin displays a similar success
 message, even though the user is not added to the site [attachment:Screen
 Shot 2017-07-01 at 12.26.20 PM.png]. This is when "Add the user without
 sending an email that requires their confirmation." is checked. When it is
 not checked, the activation email is sent out. Clicking the link brings
 you to a page with this warning: [attachment:Screen Shot 2017-07-01 at
 12.29.00 PM.png]. Ideally, this email should not go out.

 Add New User Form
 - In the network admin, submitting this form shows a success message. The
 user does not show in the table. An activation email is sent out, and the
 user is created when the link is clicked, but the user is never added to
 the site.
 - In the site admin, the experience is the same.

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


More information about the wp-trac mailing list