[wp-trac] [WordPress Trac] #20111: Ability to set permission level for admin settings pages using filters

WordPress Trac wp-trac at lists.automattic.com
Fri Feb 24 19:41:05 UTC 2012


#20111: Ability to set permission level for admin settings pages using filters
-----------------------------+------------------------------
 Reporter:  bananastalktome  |       Owner:
     Type:  feature request  |      Status:  new
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  Administration   |     Version:
 Severity:  normal           |  Resolution:
 Keywords:                   |
-----------------------------+------------------------------

Comment (by bananastalktome):

 Replying to [comment:4 ocean90]:
 > I didn't test it, but it should be possible to work with
 `$current_screen` or `$pagenow` in your filter function.

 I had dabbled with using `$current_screen`, but it was difficult to always
 know which attributes to check when I wanted to restrict a particular
 admin page for users. For example checking `$current_screen->base` was
 generally the only attribute I needed to use when blocking access to admin
 pages; however checking for the value `'post'` did not, as I had thought,
 block only Post type posts but also Pages. It was ambiguities such as this
 which caused me to have some concerns over whether the checks I had used
 were really blocking what I had intended. I figured using filters, with
 each distinct admin page in the nav menu having a separate filter which
 can be used to redefine permission levels, might make the process a little
 easier.

 I realize that this would, in some ways, complement what `$current_screen`
 can already do, but I think it might make it a little more straightforward
 and clear.

 A pie-in-the-sky wish (which actually negates the need for my proposed
 admin page permission filters) would be that the `remove_(sub)menu_page`
 functions would not only remove the page form the navigation, but also
 remove access to them (this way I could have the appropriate pages removed
 within `if (current_user_can('blah'))` blocks). But there may be a reason
 I am overlooking as to why this is not already done.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/20111#comment:5>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list