问题
I have been trying to integrate a custom Wordpress plugin called custom_rss
into Wordpress by following http://net.tutsplus.com/tutorials/wordpress/creating-a-custom-wordpress-plugin-from-scratch/
.
I have successfully achieved the proper URL in the menu items for settings
. However, when I click on the custom_rss
link under settings, the url that loads the plugin just returns content with the text You do not have sufficient permissions to access this page.
. I am logged in as the super user admin.
The script that fires when the menu item is clicked is wordpress/wp-admin/options-general.php
which passes page as its parameter :options-general.php?page=CustomRSSGenerator
.
Does anyone have any ideas about how to allow privileges for this page or better yet, has anyone found out how to do a custom plugin for Wordpress 3.5.2 who can offer a solution to my problem? This has been beating me for about a week now and any advice is appreciated.
回答1:
So there is a solution!
If you read the comments below the tutorial you will find a comment by a Robert character which states:
Great article. 2 things: 1. The following code produces an error in Admin panel, that makes the page inaccessible:
add_options_page("OSCommerce Product Display", "OSCommerce Product Display", 1, "OSCommerce Product Display", "oscimp_admin");
ERROR: "You do not have sufficient permissions to access this page."
To remove this error, modify the above code to:
add_options_page("OSCommerce Product Display", "OSCommerce Product Display", 1, "OSCommerce_Product_Display", "oscimp_admin");
That change will help you display the page correctly when the link "OSCommerce Product Display" is clicked under the "Settings" menu option. Hope this helps anyone who experienced a problem with the code.
- "The first parameter of this function is the option name which will be sued later to uniquely identify this option and its value." It should have been "used" but incorrectly spelled as "sued". Not a big deal, but just wanted to let you know.
回答2:
Posting on this old topic because it was the most relevant Google result when I was searching after running into a similar problem so I figured I'd add my fix.
I had a really similar problem where any change I made to the page slug resulted in an insufficient permission error. At first I thought my page slug must be getting referenced somewhere else in my code so I searched and found no other references. I also tried stripping away every line of code outside of the basic plugin instantiation code but it still didn't work.
The fix was to deactivate then reactivate the plugin (within admin UI). I'm guessing upon plugin activation wordpress adds various entries to it's DB; some of which are likely your plugins name, menu page names, slugs, etc. After reactivating the plugin, the exact code that previously threw permission errors now worked perfectly.
来源:https://stackoverflow.com/questions/18136064/custom-wordpress-3-5-2-plugin-you-do-not-have-sufficient-permissions-to-access