Reputation: 75
I am developing a theme setting page for my client. I want to add a theme options page to apply settings but I get Wordpress error "You do not have sufficient permissions to access this page. I think I am using the right code but problem still exists. Please help me out in figuring where I am wrong
/*
* ADD THEME SETTINGS PAGE
*/
function vc_add_theme_settings_page(){
add_theme_page('Theme Settings','Theme Settings', 'manage_options' , 'vc_theme_page', 'vc_theme_page_display' );
}
add_action('admin_init', 'vc_add_theme_settings_page');
/*
* DISPLAY THEME SETTINGS PAGE
*/
function vc_theme_page_display(){
?>
<div class="wrap">
<h2>Vc Theme Settings Page</h2>
<form action="options.php" method="POST">
<?php settings_fields('vc_section'); ?>
<?php do_settings_sections('vc_theme_page'); ?>
<?php submit_button(); ?>
</form>
</div>
<?php
}
Upvotes: 0
Views: 284
Reputation: 49
Order your code at this way:
add_action('admin_menu', 'vc_add_theme_settings_pages');
add_action('admin_head', 'theme_styles');
add_action('admin_init', 'vc_add_theme_settings_page');
function vc_add_theme_settings_page(){
add_theme_page('Theme Settings','Theme Settings', 'edit_theme_options', 'manage_options', 'vc_theme_page_display' );
}
and try change
<?php do_settings_sections('vc_theme_page'); ?>
for
<?php do_settings_sections(__FILE__); ?>
Upvotes: 1
Reputation: 3663
add_action('admin_init', 'vc_add_theme_settings_page'); //instead of this
add_action('admin_menu', 'vc_add_theme_settings_page'); //try this
Hope it will work for you.
Upvotes: 0