#35307 closed enhancement (fixed)
Pass $which variable to to restrict_manage_users action hook
Reported by: | mcbenton | Owned by: | ocean90 |
---|---|---|---|
Milestone: | 4.6 | Priority: | normal |
Severity: | normal | Version: | 4.4 |
Component: | Users | Keywords: | has-patch |
Focuses: | Cc: |
Description
The 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, 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 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.
Attachments (1)
Change History (6)
#2
@
9 years ago
I've uploaded a patch for this bug. Could you include it in the next release, please?
#3
@
9 years ago
- Keywords has-patch added; needs-patch removed
- Milestone changed from Awaiting Review to 4.6
Related: #BB2906
Hi @mcbenton, this seems like a sensible proposal. Would you like to contribute a patch for consideration? We'd need a changelog entry added to the hook doc for the new parameter.