Tagged: capability, role, settings
- This topic has 5 replies, 2 voices, and was last updated 7 years ago by
Steve.
-
AuthorPosts
-
-
January 26, 2015 at 4:58 pm #3220
angeliqueMemberHello,
I’m trying to understand how the attribute “sub-menu” for a setting page work. I saw that it takes a php file as a value but I can’t make it work.
– How do I make a new setting page under WordPress “Settings”?
– Is it possible to make a setting page under another setting page I previously created?
Thank you for your help! -
January 27, 2015 at 12:14 am #3221
SteveKeymaster1) To place a settings page under the WordPress Settings use:
'sub_menu' => 'options-general.php'
2) You can definitely make a settings page under a settings page you created. When you make a settings page, WordPress creates a url like this:
admin.php?page=my_settings_page. Use this code to place a page under this one:'sub_menu' => 'my_settings_page'
Let us know if this works for you.
-
January 27, 2015 at 5:06 pm #3223
angeliqueMemberThank you very much Steve.
I have another question. I’m trying to make those settings accessible for editors and above (admin and super admin)… with no luck. I’m sure it’s just a setting I don’t do right, but I can’t find where I’m wrong.
Here is my setting menu declaration:
add_filter('piklist_admin_pages', 'piklist_authorkit_setting_pages'); function piklist_authorkit_setting_pages($pages) { $pages[] = array( 'page_title' => __('Author Settings') ,'menu_title' => __('Author Settings', 'piklist') ,'capability' => 'edit_pages' ,'menu_slug' => 'aboutme_settings' ,'setting' => 'aboutme_settings' ,'menu_icon' => plugins_url('piklist/parts/img/piklist-icon.png') ,'page_icon' => plugins_url('piklist/parts/img/piklist-page-icon-32.png') ,'single_line' => true ,'default_tab' => 'Social Media' ,'save_text' => 'Save About Me Settings' ); return $pages; }And here is one of the tab inside:
<?php /* Title: Google Analytics Tab: Google Analytics Setting: aboutme_settings Capability: edit_pages Tab Order: 40 */ piklist('field', array( 'type' => 'text' ,'field' => 'google_analytics_id' ,'label' => __('Traking ID') ,'value' => '' ,'attributes' => array( 'class' => 'text' ) ));As a result of this, the setting pages are properly displayed for editors and above, but editors still can’t submit those setting page forms (“cheating, eh?” message). Admins can.
What am I doing wrong?
-
January 27, 2015 at 5:14 pm #3224
SteveKeymasterThe WordPress capability parameter is for only showing pages. This is default WP behavior.
To change the capability for saving settings you need to use a WP filter.
The bottom of this doc explains this.
-
January 27, 2015 at 5:18 pm #3225
angeliqueMemberOops, I didn’t see that :/
Thank you very much for your quick answer. It works perfect now.
-
January 27, 2015 at 5:21 pm #3227
SteveKeymasterGreat! Closing ticket
-
-
AuthorPosts
- The topic ‘Valid sub_menu for settings?’ is closed to new replies.