Tagged: , ,

Viewing 7 reply threads
  • Author
    Posts
    • #1003
      obisean
      Member

      Hey Guys,

      I love the plugin! I was wondering would it be possible to create a custom piklist form on the admin side, but do the form processing myself. Basically, I want to create a settings page using the piklist fields, but I want to be able to process the post data myself. I don’t want the data to go into the wp_options table, my plugin has some custom tables that I need to insert the data into.

      This may not be possible, but I figured I would give piklist a shot first.

      Thanks,
      Sean

    • #1004
      Kevin
      Keymaster

      Thanks!

      We are adding in some hooks into the form save method on the next version but regardless is sounds like you want to bypass that. So you can actually just hook into template_redirect to process your form or something around that execution point.

      add_action(‘template_redirect’, ‘your_method);

      Here is how we check the nonce in the code at the moment and you can use this in your method as well

      isset($_REQUEST[piklist::$prefix][‘nonce’]) && wp_verify_nonce($_REQUEST[piklist::$prefix][‘nonce’], plugin_basename(piklist::$paths[‘piklist’] . ‘/piklist.php’)

      Let us know if you have any more questions.

      Thanks,

      Kevin

      • #6128
        iamronen
        Member

        @Kevin

        1: is it possible to use piklist_save_field-{$scope} for this?
        if I were to set all fields in the form to the same custom scope – for example myscope would Piklist let it through, sanitize and verify the fields and then fire piklist_save_field-myscope where I could do with the form data whatever I want?

        2: would uploaded files work this way too?

        3: isn’t the action name misleading – shouldn’t it be piklist_save_fields-{$scope}

    • #1005
      obisean
      Member

      Hi Kevin,

      Wow, thanks for the speedy response! I am new to WP (moving away from years of forced Drupal) and was unaware of that hook. Making these forms with piklist will save me loads of time.

      I do have one more questions. I am having some trouble with the settings page URL. If I add a settings page like this:


      function custom_member_setting_pages($pages)
      {
      $pages[] = array(
      'page_title' => 'Member Settings' // Title of page
      ,'menu_title' => 'Members Settings' // Title of menu link
      ,'sub_menu' => 'admin.php?page=memberships' // Show this page under the THEMES menu
      ,'capability' => 'manage_options' // Minimum capability to see this page
      ,'menu_slug' => 'piklist-member-fields' // Menu slug
      ,'setting' => 'member-custom' // The settings name
      ,'save' => true // true = show save button / false = hide save button
      );

      return $pages;
      }

      The settings page is not created. The ‘sub_menu’ => ‘admin.php?page=memberships’ is an existing top level settings page from another plugin I wrote without piklist. If I substitute the sub_menu item with “options_general.php” or other menu pages like the piklist demo menu items, it works just fine. am I doing something wrong?

      Thanks again for your help. You guys are awesome!

      Take Care,
      Sean

    • #1008
      Steve
      Keymaster

      @obisean– Trying adding a high priority to the Piklist filter:

      add_filter('piklist_admin_pages', 'custom_member_setting_pages', 99);

      The Piklist filter may be executing before your custom page is built.

    • #1017
      obisean
      Member

      Hi Steve,

      Unfortunately, I couldn’t get that to work either. However, if I set the “sub-menu” item to just

      'sub_menu' => 'memberships'

      The submenu is created, but the sub menu items URL is incorrect. The url ends up being

      mysite.com/wp-admin/piklist-member-fields

      But I believe it should be

      wp-admin/admin.php?page=piklist-member-fields

      I know it is not your problem to trouble shoot my issues. So I don’t want you to think I expect you to find the answer or anything. I was just wondering if you had any clues to where this might be going wrong.

      Thanks again for your help. It is greatly appreciated.

    • #4189
      intersynergy
      Member

      I have the same problem like @obisean.
      I think it could be a bug in piklist side.

    • #4190
      intersynergy
      Member

      This is my code.
      Submenu URL for piklist admin page is /wp-admin/my-settings

      add_action( 'admin_menu', __NAMESPACE__.'\\register_my_custom_menu_page', 10 );
      
      function register_my_custom_menu_page() {
      
      	add_menu_page( 'This is only a title of page', 'Title group', 'read', 'my-top-level-slug', __NAMESPACE__.'\\test', null, 6 );
          add_submenu_page( 'my-top-level-slug', 'This is only a title of submenu', 'Submenu', 'read', 'my-slug', __NAMESPACE__.'\\test2' );
      }
      
      function test() {
          echo '<h1>Header </h1>';
      }
      
      function test2() {
          echo '<h1>Podmenu</h1>';
      }
      
      add_filter('piklist_admin_pages', 'piklist_theme_setting_pages', 99);
      function piklist_theme_setting_pages($pages)
      {
          $pages[] = array(
            'page_title' => __('Piklist Settings', 'piklist')
            ,'menu_title' => __('Settings', 'piklist')
            ,'capability' => 'read' // allow users with the capability of read to VIEW this page.
            ,'sub_menu' => 'my-top-level-slug'
            ,'menu_slug' => 'my-settings'
            ,'setting' => 'custom_settings'
            ,'menu_icon' => plugins_url('piklist/parts/img/piklist-icon.png')
            ,'page_icon' => plugins_url('piklist/parts/img/piklist-page-icon-32.png')
            ,'default_tab' => 'General'
            ,'single_line' => false
            ,'save_text' => 'Save these settings'
          );
      
        return $pages;
      }
    • #4191
      Steve
      Keymaster

      @intersynergy– Welcome to the Piklist community!

      Please be a little more specific with your issue.

Viewing 7 reply threads
  • You must be logged in to reply to this topic.