[wp-trac] [WordPress Trac] #35307: Pass $which variable to to restrict_manage_users action hook
WordPress Trac
noreply at wordpress.org
Mon Jan 4 20:44:20 UTC 2016
#35307: Pass $which variable to to restrict_manage_users action hook
-------------------------+-----------------------------
Reporter: mcbenton | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Users | Version: 4.4
Severity: normal | Keywords:
Focuses: |
-------------------------+-----------------------------
The [https://core.trac.wordpress.org/browser/tags/4.4/src/wp-
admin/includes/class-wp-users-list-table.php#L279 restrict_manage_users]
hook is placed so as to allow additional controls to be added above and
below the admin Users table. It gets called twice: once ABOVE and once
BELOW the Users table. While the containing function has awareness of the
above/below context via the {{{$which}}} variable,
[http://wordpress.stackexchange.com/questions/213576/how-to-filter-users-
on-admin-users-page-by-custom-meta-field/213587 extensions which use this
hook must jump through extra hoops to determine the context]. The
recommendation is to change the above line to:
{{{do_action( 'restrict_manage_users', $which );}}}
This will allow writers of extensions using the
{{{restrict_manage_users}}} hook not to have to resort to the workarounds
described in the StackExchange thread above.
FYI, the [https://core.trac.wordpress.org/browser/tags/4.4/src/wp-
admin/includes/class-wp-posts-list-table.php#L418 corresponding function
in class-wp-posts-list-table.php] has TWO action hooks:
{{{restrict_manage_posts}}} (which does not receive the {{{$which}}}
context variable), and {{{manage_posts_extra_tablenav}}} (which does).
Therefore an alternative solution would be to add an additional action
hook to this function corresponding to {{{manage_posts_extra_tablenav}}}
called {{{manage_users_extra_tablenav}}} that looks like:
{{{do_action( 'manage_users_extra_tablenav', $which );}}}
The benefit of this second solution is that it creates parity between User
and Post administration hooks, and it also avoids the possibility of
corrupting any extensions based on the current {{{restrict_manage_users}}}
hook.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/35307>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list