Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#5379 closed enhancement (fixed)

Add admin_menu_permission hook to menu.php

Reported by: donncha Owned by: westi
Milestone: 2.5 Priority: normal
Severity: normal Version: 2.3.1
Component: General Keywords:
Focuses: Cc:


WordPress MU has a modified wp-admin/menu.php but with the addition of a new hook just above the user_can_access_admin_page() check, those custom mods can go into a new file.

I called the action admin_menu_permission as there are hooks above for modifying the admin menu, this hook wouldn't have any other function AFAICT.

I did try hooking on to admin_menu but it didn't work and the user received the standard WP "cannot access page" error instead of being redirected as WordPress MU usually does.

Please take a look at the attached file.

Attachments (1)

menu.php.diff (382 bytes) - added by donncha 8 years ago.

Download all attachments as: .zip

Change History (6)

8 years ago

#1 @westi
8 years ago

  • Owner changed from anonymous to westi
  • Status changed from new to assigned

Looking at the mu code (http://trac.mu.wordpress.org/browser/trunk/wp-admin/menu.php) would we not do better with an action inside the failure case:


if (! user_can_access_admin_page()) { 
    wp_die( __('You do not have sufficient permissions to access this page.') ); 

mu can then hook on that and do the redirect if necessary before the wp_die

#2 @westi
8 years ago

This could also then be used by any WordPress plugins that wanted to track things like attempts to access pages that the user didn't have the rights to.

#3 @donncha
8 years ago

Good idea, looks better inside the if() condition.

#4 @westi
8 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [6356]) Allow plugins to handle admin page access failures. Fixes #5379 props donncha

#5 @westi
8 years ago

  • Milestone changed from 2.3.2 to 2.4
Note: See TracTickets for help on using tickets.