Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > Web 2.0, Mashups, and Other Web Programming > BOOK: Professional WordPress
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional WordPress
This is the forum to discuss the Wrox book Professional WordPress by Hal Stern, David Damstra, Brad Williams; ISBN: 9780470560549
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional WordPress section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 3rd, 2010, 11:30 AM
Registered User
 
Join Date: Jul 2010
Location: Edmonds, WA
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Permissions issue when creating an admin sub-menu

So I'm working on Chapter 7 Plugin Development. I've created a function that adds the submenu to an existing menu. However, when I click on that submenu item I get an error "You do not have sufficient permissions to access this page". I'm working in WordPress 3.0 and am using the following code:

PHP Code:
function ttwtih_create_menu_item(){
    add_submenu_page('thesis-options', __('Image Header', 'thesis'), __('Image Header', 'thesis'), 'edit_themes', __FILE__, 'ttwtih_settings_page');
}

function ttwtih_settings_page(){
    ?>
    <div id="thesis_options" class="wrap">
    <?php
    thesis_version_indicator
();
    
thesis_options_title(__('Image Header Options''thesis'));
    
thesis_options_nav();
    
?></div>
    <?php
}
Any suggestions for a solution?

Spectacular book by the way. I'm a subscriber to Wrox 24/7 but couldn't wait till they put it online so actually had to purchase a hard copy!
Reply With Quote
  #2 (permalink)  
Old July 3rd, 2010, 01:46 PM
Registered User
 
Join Date: Jul 2010
Location: Edmonds, WA
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Further clarification

The problem here seems to be that I am trying to add a submenu page to an already existing Theme menu using my plugin.

I don't want to hack the Thesis core to add the submenu there so I'm hoping there is a way to add the submenu by using the add_submenu_page in my plugin.
Reply With Quote
  #3 (permalink)  
Old July 9th, 2010, 09:16 AM
Wrox Author
Points: 33, Level: 1
Points: 33, Level: 1 Points: 33, Level: 1 Points: 33, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2010
Location: New Jersey
Posts: 7
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hey Rick,

How are you calling your ttwtih_create_menu_item() function? I tested your code on a Thesis 1.7 install and it worked fine for me. Make sure you are using the admin_menu action hook to register your submenu like so:

PHP Code:
add_action('admin_menu''ttwtih_create_menu_item'); 
So the full code snippet would be:

PHP Code:
add_action('admin_menu', 'ttwtih_create_menu_item');

function ttwtih_create_menu_item(){
    add_submenu_page('thesis-options', __('Image Header', 'thesis'), __('Image Header', 'thesis'), 'edit_themes', __FILE__, 'ttwtih_settings_page');
}

function ttwtih_settings_page(){
    ?>
    <div id="thesis_options" class="wrap">
    <?php
    thesis_version_indicator
();
    
thesis_options_title(__('Image Header Options''thesis'));
    
thesis_options_nav();
    
?></div>
    <?php
}
Place the above code in your custom_functions.php Thesis file and the menu will work perfectly.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with hiding Admin from the menu yevi BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 7 April 3rd, 2009 06:36 AM
ASP.NET 2.0 Web Site Admin error on Creating User fmegersa ASP.NET 2.0 Basics 0 December 1st, 2006 08:57 PM
Creating directory with NTFS permissions eelisMX Pro VB.NET 2002/2003 0 May 10th, 2006 08:16 AM
creating new user with admin rights... dungey MySQL 1 April 20th, 2004 06:08 PM



All times are GMT -4. The time now is 08:00 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.