PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Adding entries as posts with visibility: private

  1. prij
    Member

    Hi,

    Just wondering if there's a way I can save a form entry as a blog post with visibility: private using Gravity Forms?

    Ideally, when the user completes a form they will be able to check a checkbox which allows them to make their submission private.

    On submission, if this checkbox has been selected, then the entry should be saved as a private post, otherwise the entry would save as a regular post with public visibility.

    Posted 13 years ago on Sunday March 20, 2011 | Permalink
  2. Give this a shot: http://pastie.org/1696947

    Posted 13 years ago on Monday March 21, 2011 | Permalink
  3. ckrauskopf
    Member

    Hi, it looks like prij got his form working, I've got a slight variation on this. I'd like to make all posts generated by my form private. I'm also using the GF custom post types plugin to make the form generate a custom post type called 'submissions' rather than a regular post, which I hope doesn't complicate things too much. I don't want the privacy to be conditional on the answer to any of the form questions, I just need all 'submissions' to be visible only to administrators. Actually, it could be any logged in user, but it must be invisible to the public.

    Any ideas? Here is the test form:

    http://www.christopherkrauskopf.me/test/blu/new-form-test/

    Posted 12 years ago on Tuesday February 28, 2012 | Permalink
  4. This oughta do the trick:

    http://pastie.org/3481479

    Posted 12 years ago on Tuesday February 28, 2012 | Permalink
  5. ckrauskopf
    Member

    OK - I'm not sure if I did this right or not, but it doesn't seem to be working. I put the code below in my functions.php - then I submitted the form which created a new 'submission' but it was still set to public.

    // update '39' to the ID of your form
    add_filter('gform_post_data_39', 'set_post_private');
    function set_post_private($post_data){
        global $post;
        $post_data['post_status'] = 'private';
        return $post_data;
    }

    Once again the form is here: http://www.christopherkrauskopf.me/test/blu/new-form-test/

    The theme is Nova by Elegant Themes. I really appreciate your help.

    Posted 12 years ago on Tuesday February 28, 2012 | Permalink
  6. ckrauskopf
    Member

    Hi Guys,

    Just wanted to post and say I got this working with the exact same code David posted above in this thread. I'll clarify what I did and why I was confused in case it helps other noobs like me that might have the same issues. The code in question is posted in my previous comment above.

    1) This code does go into functions.php.
    2) I was confused by the comment "// update '39' to the ID of your form"
    '39' refers to the word 'id' not to the word 'update'. Each form has an id, mine ended up being '3'. So gform_post_data_3 identifies my form, and adds the filter function in the right place.

    Here are other helpful threads on the subject that helped me figure this out.

    http://www.gravityhelp.com/forums/topic/gf-post-field-visibility-private-option
    http://www.gravityhelp.com/documentation/page/Gform_post_data

    Thanks for your help David, I know everything I just wrote must seem remarkably obvious to you, but hopefully it will be of use to some future forum user.

    Posted 12 years ago on Thursday March 1, 2012 | Permalink