Viewing 2 reply threads
  • Author
    Posts
    • #5950
      jivedig
      Member

      I have a form to submit new posts on front end. It has a field to select post status when submitting. I’d like to hide this post when editing a published post via /?_post[ID]=1234

      Using:

      'on_post_status' => array(
            'hide' => 'publish',
       ),

      … doesn’t work when editing a post this way. I could hack something together to work, but would love Piklist core to handle this somehow if possible. Any thoughts?

    • #5951
      jivedig
      Member

      FWIW, this is how I’m successfully doing this now.

      $edit_post_data      = isset($_GET['_post']) ? $_GET['_post'] : null;
      $edit_post_id        = isset($edit_post_data['ID']) ? absint($edit_post_data['ID']) : -1;
      $edit_post_status    = get_post_status($edit_post_id);
      $edit_post_published = ( 'publish' === $edit_post_status ) ? true : false;
      
      // Hide field if editing a published post
      if ( ! $edit_post_published ) {
          // My piklist field(s)
      }
    • #5971
      Steve
      Keymaster

      @jivedig– Great solution! on_post_status doesn’t work on frontend forms.

      One of the benefits of Piklist is that its code based, you can use standard PHP conditions to hide/show fields. Great job.

Viewing 2 reply threads
  • The topic ‘on_post_status when editing post with front end form’ is closed to new replies.