WordPress.org

Make WordPress Core

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#3533 closed defect (bug) (worksforme)

Admin pages created by Plugins get permissions errors

Reported by: mattyrob Owned by:
Milestone: Priority: high
Severity: major Version: 2.0.6
Component: Administration Keywords:
Focuses: Cc:

Description

In my plugin I have the following line:

add_submenu_page('profile.php', ('Subscriptions', 'subscribe2'), ('Subscriptions', 'subscribe2'), "read", FILE, array(&$this, 'user_menu'));

This adds a submenu to profile.php so users can manage email subscriptions.

Since 2.0.6 it is no longer working - the menu is available but clicking on it gives an error message:

"You do not have sufficient permissions to access this page."

From my back tracking through the WP code, it appears that the issue arises in the user_can_access_admin_page() function. I haven't figured out a fix other than hacking out the if statement at the end of menu.php.

Attachments (1)

test.php (413 bytes) - added by markjaquith 14 years ago.
Menu test plugin

Download all attachments as: .zip

Change History (9)

#1 @markjaquith
14 years ago

Are you sure your user has the "read" capability?

#2 @mattyrob
14 years ago

Yes, I'm sure that the user has "read" capability as:

1/ they are a registered WP blog user with WP user-level 0 in the database

2/ they can access Dashboard and Profile menus

3/ It worked from 2.0.0 thru 2.0.5 with no problems

On further digging there is a commented "echo" command in the user_can_access_admin_page() function that lists the menu array. If this line of code is allowed to execute for a level 0 users the menu array is different for each option.

For Dashboard
parent array: index.php
parent array: post.php
parent array: edit.php
parent array: link-manager.php
parent array: themes.php
parent array: plugins.php
parent array: profile.php
parent array: options-general.php
parent array: import.php

For Profile->My Profile
parent array: index.php
parent array: post.php
parent array: edit.php
parent array: link-manager.php
parent array: themes.php
parent array: plugins.php
parent array: profile.php

For Profile->Subscriptions
parent array: index.php
parent array: post.php
parent array: edit.php
Followed by the access error message

Could it be to do woth the menus are being constructed differently? Especially as I also hook another page into the edit.php page.

#3 @markjaquith
14 years ago

I can't recreate. Try the test plugin (test.php) that I'm about to upload.

@markjaquith
14 years ago

Menu test plugin

#4 @mattyrob
14 years ago

Okay, things are getting more weird.

With only my plugin actived I get the menu as an option but selecting it gives error message.

With only your menu test plugin activated I get the test menu and your "it works" message!

With both active everything works as normal!

The only difference I can see generally is that you use a function to call the class but in my plugin the function is within the class. Am I calling things the wrong way around?

#5 @markjaquith
14 years ago

Can you upload your code as an attachment to this ticket? I'll take a look see.

#6 @mattyrob
14 years ago

Rather than upload it you can take a look at the code on the SVN site (unless you really want it uploaded.

SVN is:

http://dev.wp-plugins.org/browser/subscribe2/tags/2.2.9/wp-content/plugins/subscribe2/subscribe2

#7 @mattyrob
14 years ago

  • Resolution set to worksforme
  • Status changed from new to closed

Update:

Previously all me code was in a class and a "new" command called it into WordPress

I've amended my code at the end of the plugin and constructed a call to the class from a function hooked into 'init'.

This now works for me :-) Thanks for your help.

Still a little weird why it suddenly stoped working though.

#8 @Nazgul
14 years ago

  • Milestone 2.0.7 deleted
Note: See TracTickets for help on using tickets.