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.

GF Post Field Visibility Private Option?

  1. I'm using GF to create an application style form, where the entries are saved as blog posts to a custom post type. All that is working perfectly, however, all submitted entries by default go to visibility: public.

    I do not want these entries to appear via the search etc and want them to be visibility: private.

    Is there a way that I can select when creating a new form (using the Post Fields) an option to switch the visibility if I want all entries submitted for that form to be private?

    Posted 12 years ago on Friday January 20, 2012 | Permalink
  2. Hi, Syrehn,

    Using some custom code with the "gform_post_data" hook, you can set the status of the post. For more documentation on that hook, see http://www.gravityhelp.com/documentation/page/Gform_post_data . For more info on what can be changed on a post, see WordPress' documentation here: http://codex.wordpress.org/Function_Reference/wp_insert_post

    Below is an example of how to do it:

    //set status for post to private
    add_filter("gform_post_data", "set_post_status", 10, 2);
    function set_post_status($post_data, $form){
        //only do this when the form id is 23
        if($form["id"] != 23)
           return $post_data;
    
    	$post_data["post_status"] = "private";
        return $post_data; //return the changed data to use when the post is created
    }
    Posted 12 years ago on Friday February 3, 2012 | Permalink
  3. Hi Dana,
    I wish this "visibility" feature was an option within the "Title / post" element in Gravity Forms.

    I'm afraid I need a little more explanation please? How do I find out information on using the "gform_post_data" hook.? While I see the examples I don't think it tells me where to post it or how to handle it or install this code.

    My Gravity Forms is installed on a multiblog site. Does that impact on the solution?

    Thanks for your help.

    Posted 12 years ago on Friday February 10, 2012 | Permalink
  4. Hi, Stuart,

    I will talk to the team about adding visibility as an option; it seems like a useful thing to have. Maybe in a future release.

    The documentation for the gform_post_data hook can be found at - http://www.gravityhelp.com/documentation/page/Gform_post_data

    The example I provided is something you would put in your theme's functions.php file. In the example my form id was 23, you would change that to your form id. You can find out your form id in the admin. The ID is listed to the left of the form title. This example will do exactly what you need so you can paste it in your file and change the form id.

    Let me know if you still have questions.

    Posted 12 years ago on Friday February 10, 2012 | Permalink
  5. Yes please on visibility! I tried dropping your code into my custom-functions.php file which is part of my Thesis theme. That worked for what people see on the PC. However, here's the complication. I am using WPTouchPro for mobile. The same form displayed in the WPTouch Pro style doesn't get this same correction. So I presume I have to find the Functions file for it too. I will see if I can get that working too.

    The reason I'm working to enable this is.
    --- I have a "respondents form" - I want respondents to be able to see their own posts but not everyone's posts. (I'd also like to eliminate the "Private" on their posts too). By enabling the above I can publish their posts rather than mark them pending and make private manually.
    --- The "moderators" can then see all the entries/responses as they can see protected posts. However, for them the "Private" is just an eyesore. An alternative would be to enable a different value for "private" - for example "submission".

    Posted 12 years ago on Saturday February 11, 2012 | Permalink
  6. I also need this. Has this been fixed please?

    Posted 12 years ago on Sunday July 15, 2012 | Permalink
  7. David Peralty

    Currently you still have to use the hooks system if you don't want the post to be either: Draft, Pending Review or Published right away.

    Posted 12 years ago on Monday July 16, 2012 | Permalink
  8. Hi,

    i would like to have the possibility that users chose the post visibility (public, password protected, private) ussing the radio button option and if they chose visibility=password protected , then appear the field "password" to be completted.

    I have created the whole layout but the form is not submiting the chesed options.
    Can you help me to setup this?

    Thanks
    Marcos

    Posted 11 years ago on Sunday April 14, 2013 | Permalink