开发者 |
jcow
ekaj jr00ck p51labs |
---|---|
更新时间 | 2015年7月3日 04:53 |
捐献地址: | 去捐款 |
PHP版本: | 3.6.1 及以上 |
WordPress版本: | 4.2.2 |
版权: | GPLv2 or later |
版权网址: | 版权信息 |
[gravityform id="1" update] // Loads current post for editing
[gravityform id="1" update="34"] // Loads post where ID=34 for editing
We worked with Rocketgenius, makers of Gravity Forms, to get a small upgrade added that allows us to extend their shortcode, so now you can simply add the "update" attribute to the normal "gravityform" shortcode. If you only add "update", it will load the current post in to update. If you add an integer to the update attribute, it will use that to load a post by its ID.
URL QUERY VARIABLE
do_action('gform_update_post/edit_link');
do_action('gform_update_post/edit_link', array( 'post_id' => $post->ID, 'url' => home_url('/edit_post/'), ) );
Arguments (query string or array)
post_id
(int) (optional) The id of the post you want to edit. Default: global $post->IDurl
(string|int) (optional) Either the full url of the page where your edit form resides, or an id for the page/post where the edit form resides. Default: get_permalink()text
(string) (optional) The link text. Default: "Edit Post"title
(string) (optional) The title attribute of the anchor tag. Default: (text) parameterapply_filters('gform_update_post/edit_url', '');
Specify post to edit (post_id) and post that holds the edit form (url)
apply_filters('gform_update_post/edit_url', 1, home_url('/edit_post/'));
Shortcode to show the edit link
[gform_update_post_edit_link]
Specify post to edit (post_id) and post that holds the edit form (url)
[gform_update_post_edit_link post_id=1 url=6]
IN TEMPLATE
You can use the action to force a form show a specific post:
do_action('gform_update_post/setup_form');
do_action('gform_update_post/setup_form', $post->ID);
do_action('gform_update_post/setup_form', array('post_id' => $post->ID, 'form_id' => $form_id));
Parameters
post_id
(int|array) (optional) The id of the post you want to edit or an array with post id and/or form id. This allows you to specify the form id, so that update functionality does not get applied to other forms on the page. Default: global $post->IDTags really only work with a single line text field, checkbox and multiselect currently won't show the selected items when loaded for editing, but they will select the items. This might get changed in the future, but isn't pressing. Categories support those other methods, and the text field seems more appropriate, over all, for the tags.
Image fields are only supported if they are the "Featured Image". Otherwise you have to use a Custom Field and choose "File Upload" under File Type. If it is not one of these two types, we can't track it for updating.
It usually means you are running PHP 5.2.x on your server. I know WordPress supports 5.2.4, but it is highly recommended to run at least 5.4, and this plugin simply doesn't support older than 5.3. We tried a little bit, but we could not get anonymous functions to work in a format that was compatible with 5.2, and, honestly, we really don't want to spend a lot more time on it, because 5.2 is so old, and you should upgrade. We did try though...