WordPress.org

Ready to get started?Download WordPress

Forums

Gravity Forms - Update Post
pass post ID within shortcode? (15 posts)

  1. Brandon Kraft
    Happiness Engineer
    Posted 1 year ago #

    Hi,

    I'm trying to use this plugin within the context of a shortcode. (I'm using a page template to conditionally show the form and other content based on the role of the current user).

    Can I do this within the typical Gravity Forms shortcode, or do I need to filter something in my function.

    http://wordpress.org/extend/plugins/gravity-forms-update-post/

  2. srumery
    Member
    Posted 1 year ago #

    I'm looking for the answer to this as well. Not by using a shortcode but by passing the post id directly from the page template. I have not found the proper solution yet. Any luck on your end?

  3. jcow
    Member
    Posted 1 year ago #

    I don't have a short code, but I did add a function to interface with the plugin so that I could add the post id through php instead of with a GET variable. It would be used to create a short code.

    This is my update:

    Overview | Download

    This is still being tested by me, but it is working for what I need so far. I needed to remove GET variable dependancy and to be able to update files. The file part isn't very graceful, but it is working.

  4. myhero
    Member
    Posted 10 months ago #

    hi jcow,

    Thanks for your contribution.

    I've downloaded your update and replaced the original with yours.

    and added the code given below to my functions.php.

    add_filter( 'gform_update_post_settings', 'custom_gform_update_post_settings' );
    
    function custom_gform_update_post_settings( $settings )
    {
        $settings['request_id'] = 'edit_id';
        return $settings;
    }

    But I cannot get it setup, what would I need to add/change/remove in order to get this to work?

  5. jcow
    Member
    Posted 10 months ago #

    The setting you used isn't very important.

    If you want to have a form edit a post, you need to pass that post's id to the form using one of two methods. Either add the post id to the url using the GET variable set up by this plugin "gform_post_id" or with the updated version of the plugin, you can pass the post id through a function instead.

    Example 1, url for the current page:
    http://example.com/path/to/edit/page/?gform_post_id=24

    Example 2, in your page template:

    gravityforms_update_post('setup_form', 24);
    gravity_form(1);

    The code you added to functions.php will simply change gform_post_id to edit_id.

    So after adding that to your functiions.php, you would use:
    http://example.com/path/to/edit/page/?edit_id=24
    instead of:
    http://example.com/path/to/edit/page/?gform_post_id=24

  6. wpoo
    Member
    Posted 10 months ago #

    Using

    gravityforms_update_post('setup_form', 24);
    gravity_form(1);

    (24 = the post's id you want to update, 1 = the form's id)
    a third user will not be able to change the desired post id by adding /?gform_post_id=1 to the url (in order he wants to edit the post with id=1). That's a good point and big improvement by jcow

    btw jcow,

    I don't want to be rude or impolite but I do not know if you noticed the issue on https://bitbucket.org/jupitercow/gravity-forms-update-post/issue/1/previously-uploaded-file that I added.

    I don't get how to..: [...]It also keeps the file from being removed from the field on save when nothing new was added.[...]

    Could you specify the feature's setup?

  7. jcow
    Member
    Posted 10 months ago #

    It has been a while since I looked at that, I need a few minutes to review it. Hopefully that will happen to tomorrow, but feel free to ping me, if you don't hear anything.

  8. wpoo
    Member
    Posted 10 months ago #

    That'd be great to see! Thank you

  9. myhero
    Member
    Posted 10 months ago #

    Hi jcow thanks for getting back to me! and thanks for the input wpoo.

    Excuse my ignorance but will I have to setup 2 separate forms one for the post submission and another for editing the post or can I setup one form that will be able to do both functions?

    Thank you

  10. myhero
    Member
    Posted 10 months ago #

    This is what I want to do:

    - Users must submit my form (from their dashboard) which will in turn submit a post
    - The user must be able to edit the same post using the same form on the dashboard

    If multiple users submit the same form from their dashboard, will the post ID be unique for each post?

    From the code:

    gravityforms_update_post('setup_form', 24);
    gravity_form(1);

    Where 24 is the Post ID and (1) is the from ID. It seems that this is a fixed post ID that would link to one post only, or am I mistaken, will it support multiple posts from different users?

    Am I able to achieve this using this plugin? Or will custom work be needed?

  11. cynarad
    Member
    Posted 10 months ago #

    When I use the function call "gravityforms_update_post('setup_form', $post_id);" to pass the post id, I receive an Error 500.

    The debug log says: PHP Fatal error: Call to undefined function gravityforms_update_post() .

    Any idea why this function can't be found??

    I am using wordpress 3.6.

  12. myhero
    Member
    Posted 10 months ago #

    cynarad, have you managed to get yours setup?

  13. cynarad
    Member
    Posted 10 months ago #

    No, I still get the message "PHP Fatal error: Call to undefined function gravityforms_update_post()"

  14. jcow
    Member
    Posted 10 months ago #

    There was definitely a bug before. The previous was version was a really quick fix to get it working for me, since the plugin hasn't been updated in a long time and appears to be orphaned.

    In the past couple weeks, I rewrote the whole thing. See the new write up for a better explanation:
    https://bitbucket.org/jupitercow/gravity-forms-update-post

    Let me know what issues you come upon in the issues system on bitbucket, since this plugin is really completely different than the plugin here, there i no reason to try and support it here currently.

    I will work on getting these updates into the WordPress plugin repository in the future.

  15. jcow
    Member
    Posted 10 months ago #

    The new version also DOES have a shortcode. It... isn't ideal. You have to add an extra short code in front of the gravity form shortcode, but it is a shortcode...

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.