Viewing 2 reply threads
  • Author
    Posts
    • #6114
      digger149
      Member

      hello, sorry to trouble you again..

      I am creating a CPT (ticket) from a front-end form, but I can’t get the piklist_empty_post_title to work.

      I have created the plugin and set the piklist_empty_post_title code as below

      add_filter('piklist_post_types', 'ticket');
       function ticket($post_types)
       {
        $post_types['ticket'] = array(
          'labels' => piklist('post_type_labels', 'Ticket')
       ,'title' => __('Enter add new Ticket')
          ,'public' => true
            ,'show_in_nav_menus' => true
          ,'has_archive' => true
          ,'rewrite' => array(
            'slug' => 'ticket'
      
          )
          ,'supports' => array(
            'author'
      
          )
          ,'hide_meta_box' => array(
            'slug'
      
            ,'revisions'
            ,'comments'
            ,'commentstatus'
          )
          ,'capability_type' => 'post'
          ,'edit_columns' => array(
              'title' => __('Title'))
      
        );
      return $post_types;
      }
      
      function set_post_title_to_order_number($data, $post_array)
      {
      
        if ($post_array['post_type'] == 'ticket')
        {
      
       print_r($post_array); // output
          die();
      
          return 'Ticket #' .  $post_array['ID'];
      
        }
        else
        {
          return $data;
        }
      
      }
      add_filter('piklist_empty_post_title', 'set_post_title_to_order_number', 10, 2);
      
      ?>

      The front end form is

      Title: Ticket Form
      Method: post
      Logged in: true
      Redirect: /test/
      
      */
      
        // Where to save this form
        piklist('field', array(
          'type' => 'hidden'
          ,'scope' => 'post'
          ,'field' => 'post_type'
          ,'value' => 'ticket'
        ));
      
      piklist('field', array(
       'type' => 'hidden'
       ,'scope' => 'post'
        ,'field' => 'post_status'
        ,'value' => 'publish'
       ));
      ...
      ...

      It’s running the filter, because print_r($post_array); works – but ALL the fields in ths array are empty.

      The CPT is actually being posted, I can see all the data in the WP-Admin, but the post title is always blank

      Any help would be very much appreciated

    • #6116
      digger149
      Member

      I have just discovered that it works properly if the custom post is created in the admin backend, it must be something to do with the front end form processing

    • #6147
      Steve
      Keymaster

      @digger149– Thanks for letting us know. We’ll take a look.

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