Viewing 5 reply threads
  • Author
    Posts
    • #3220
      angelique
      Member

      Hello,

      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!

    • #3221
      Steve
      Keymaster

      @angelique

      1) 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.

    • #3223
      angelique
      Member

      Thank 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?

    • #3224
      Steve
      Keymaster

      The 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.

    • #3225
      angelique
      Member

      Oops, I didn’t see that :/

      Thank you very much for your quick answer. It works perfect now.

    • #3227
      Steve
      Keymaster

      Great! Closing ticket

Viewing 5 reply threads
  • The topic ‘Valid sub_menu for settings?’ is closed to new replies.