Viewing 2 reply threads
  • Author
    Posts
    • #5805
      kattagami
      Member

      Hello,

      I try to update a CPT with a front end form.

      I call my form with an URL like this:

      
      http://xxx.com/my-form/?action=presentation&_post[ID]=57
      

      And this is the code from my form file:

      
      <?php
      /*
      Method: post
      */
      
      piklist( 'field', 
                      array(
                              'type'  => 'hidden',
                              'scope' => 'post',
                              'field' => 'post_type',
                              'value' => 'presentation',
                      )
      );
      
      piklist( 'field', 
                      array(
                              'type'          => 'text',
                              'scope'         => 'post',
                              'field'         => 'post_title',
                              'label'         => esc_html__( 'Title' , 'katt' ),
                      )
      );
      
      piklist( 'field', 
                      array(
                              'type'          => 'textarea',
                              'scope'         => 'post',
                              'field'         => 'post_content',
                              'label'         => esc_html__( 'Content' , 'katt' ),
                              'attributes' 	=> array(
              					   'rows' => 10,
              					   'cols' => 50,
              					   'class' => 'katt-proposition-content',
      										 )
                      )
      );
      
      piklist( 'field', 
                      array(
                          'type'              => 'submit',
                          'field'             => 'submit',
                          'value'             => esc_html__( 'Submit' , 'katt' ),
                          'attributes'        => array(
                                                      'class' => 'button button-primary',
                                              )
                      )
      );
      

      1- My inputs form are empty and not populated by the id=57 “presentation” CPT data.
      Do I need to do it myself with a get_post_type($args) function or Piklist is supposed to do it itself?
      If I put some content in the (empty) fields and submit the form, my id=57 CPT is updated. However, the front end input fields remain empty.

      2- Have got some warning messages on each fields (Mode debug > true)
      Warning: Illegal string offset ‘field’ in /xxx/wp-content/plugins/piklist/includes/class-piklist-form.php on line 926

      See my screenshot

      Attachments:
      You must be logged in to view attached files.
    • #5814
      kattagami
      Member

      Typo in my previous message:

      “Do I need to do it myself with a get_post($ID) function …”

    • #6067
      jivedig
      Member

      I don’t think you need the cpt name in the query string. WP uses unique ID’s regardless of post_type. I have this working with just ?_post[ID]=57 on a CPT.

Viewing 2 reply threads
  • The topic ‘Front end form, update a CPT’ is closed to new replies.