admin管理员组文章数量:1429108
(Moderator's note: Original title was "Getting error: You do not have sufficient permissions to access this page. Trying to build custom plugin")
I'm trying to write my own custom WordPress plugin, but as soon as I click on the menu I get the following error:
You do not have sufficient permissions to access this page.
My plugin is located under:
/wp-content/plugins/wp-e-commerce-group-pricing/wp-e-commerce-group-pricing.php
The code is below, I'm new to WordPress, so maybe I'm doing something wrong:
if ( is_admin() ) {
// Hooks and admin menu setup
add_action('admin_menu', 'add_options_gp');
function add_options_gp() {
add_submenu_page('wpsc-sales-logs','WPEC - Group Pricing','Group Pricing',7,
'wp-e-commerce-group-pricing', 'price_options');
}
function price_options(){
// Page content goes here...
}
}
(Moderator's note: Original title was "Getting error: You do not have sufficient permissions to access this page. Trying to build custom plugin")
I'm trying to write my own custom WordPress plugin, but as soon as I click on the menu I get the following error:
You do not have sufficient permissions to access this page.
My plugin is located under:
/wp-content/plugins/wp-e-commerce-group-pricing/wp-e-commerce-group-pricing.php
The code is below, I'm new to WordPress, so maybe I'm doing something wrong:
if ( is_admin() ) {
// Hooks and admin menu setup
add_action('admin_menu', 'add_options_gp');
function add_options_gp() {
add_submenu_page('wpsc-sales-logs','WPEC - Group Pricing','Group Pricing',7,
'wp-e-commerce-group-pricing', 'price_options');
}
function price_options(){
// Page content goes here...
}
}
Share
Improve this question
edited Feb 8, 2011 at 13:10
MikeSchinkel
37.6k14 gold badges117 silver badges132 bronze badges
asked Feb 8, 2011 at 12:47
ElitmiarElitmiar
2073 silver badges10 bronze badges
2
|
2 Answers
Reset to default 4I think the issue may be in your call to add_submenu_page()
:
add_submenu_page('wpsc-sales-logs',...
The first parameter needs to be a reference to your Menu Page's "slug", i.e. if you use 'edit.php'
instead you'll see that you get a menu option under the "Posts" menu page:
add_submenu_page('edit.php','WPEC - Group Pricing','Group Pricing', 7,
'wp-e-commerce-group-pricing', 'price_options');
Here's what it looks like:
(source: mikeschinkel)
So you need to find out what URL fragment (the part past http://yoursite/wp-admin/
) that your menu page uses.
UPDATE
For future readers, Roland's issue was a hook priority issue. Changing priority from 10 to 11 fixed it in his case:
add_action('admin_menu', 'add_options_gp',11);
P.S. You really don't need the if
statement testing for is_admin()
since you are using the 'admin_menu'
hook; it only fires in the admin.
Does it show up and work if you add it as sub menu page to some other menu item? Please try this to make shure it works and the only problem is the slug. Some point i'd suggest to look is the parent plugin folder and a search for add_menu_page in there.
If you look into your wp ecommerce folder: wp-e-commerce > wpsc-admin > admin.php on line 71-96 you'll find the way how it's done in the plugin.
@Mike: Here's the download link
try to use add_object_page( $page_title, $menu_title, $access_level, $file, $function = '', $icon_url = '');
with 'admin.php?page=wpsc-sales-logs'
or 'wpsc-sales-logs'
.
Or try to use something like add_submenu_page('wpsc-sales-logs', __('WPEC - Group Pricing', 'wpsc'), __('Group Pricing', 'wpsc'), 7, 'wpsc-sales-logs', 'price_options');
or take a look at the reference from wp-e-commerce plugin files at (file from above) line 99-108
版权声明:本文标题:Menu Error in Admin Console with Custom Plugin: You do not have sufficient permissions to access this page 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745499562a2660965.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
add_submenu_page()
but where is youradd_menu_page()
for'wpsc-sales-logs'
? – MikeSchinkel Commented Feb 8, 2011 at 12:53