Title: Edit post
Last modified: October 29, 2022

---

# Edit post

 *  Resolved [athep](https://wordpress.org/support/users/athep/)
 * (@athep)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/edit-post-14/)
 * Hello!
 * I was wondering if it was possible to pre-fill a form page with a previously 
   submitted entry for easier non-backend editing, how can I achieve this?

Viewing 9 replies - 1 through 9 (of 9 total)

 *  Plugin Author [Aurovrata Venet](https://wordpress.org/support/users/aurovrata/)
 * (@aurovrata)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/edit-post-14/#post-16168791)
 * yes you can, see [FAQs](https://wordpress.org/plugins/post-my-contact-form-7/#faq)
   20 and 23
 *  Thread Starter [athep](https://wordpress.org/support/users/athep/)
 * (@athep)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/edit-post-14/#post-16169068)
 * Thank you!
 *  Thread Starter [athep](https://wordpress.org/support/users/athep/)
 * (@athep)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/edit-post-14/#post-16169357)
 * Hello, I read the F.A.Q and also watched your video on this topic, I’d like to
   ask how I would go about creating a link that would pre-fill the add post page
   with the post I want edited, this means the link passing the post ID?
 * I’m not very proficient with backend so I did my best to implement the code you
   added on your F.A.Q
 * Also thank you for the life saving plugin! Great work.
 *  Plugin Author [Aurovrata Venet](https://wordpress.org/support/users/aurovrata/)
 * (@aurovrata)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/edit-post-14/#post-16172316)
 * > how I would go about creating a link that would pre-fill the add post page 
   > with the post I want edited, this means the link passing the post ID?
 * Sure, but i would pass it as a query parameter to your link, something like `
   yourdomain.com/form-edit/?pid=123`
 * On your `form-edit` page you want to look for your [$_GET](https://stackoverflow.com/a/1018970/3596672)
   query parameter and then ensure the post is editable by the current user (as 
   a security option to stop someone hacking the link).
 * Now you can do either of 2 things,
 * 1. if the current user is the author of the post, then simple set the post’s 
   meta field `_cf7_2_post_form_submitted` to `no` and the plugin will pick up that
   post for editing, pre-filling the values in the mapped form.
 * 2. You can by-pass the post query by forcing the post to be loaded for this query,
   for example the `post__in` [property](https://developer.wordpress.org/reference/classes/wp_query/#post-page-parameters)
   using the filter `cf7_2_post_filter_user_draft_form_query` (you have a helper
   code available in the form’s editor page Actions & Filters metabox (see the [screenshot](https://wordpress.org/plugins/post-my-contact-form-7/#screenshots)#
   8).
 *  Plugin Author [Aurovrata Venet](https://wordpress.org/support/users/aurovrata/)
 * (@aurovrata)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/edit-post-14/#post-16172340)
 * PS: another way is to programmatically load the form shortcode and add the `cf7_2_post_id`
   attribute, but you will still need to do step 1 above.
 * `do_shortcode('[contact-form-7 id=... cf7_2_post_id=123]');`
 *  Thread Starter [athep](https://wordpress.org/support/users/athep/)
 * (@athep)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/edit-post-14/#post-16223007)
 * I’m not good with PHP, I did however got a bit lucky with this snippet, this 
   is after checking the author credentials and all.
 *     ```
       $pid = $_GET['pid'];
       if( isset( $pid ) && get_post_status( $pid ) ) {
       	update_post_meta($pid, '_cf7_2_post_form_submitted' ,'no');
       } else {
       	update_post_meta($pid, '_cf7_2_post_form_submitted' ,'yes');
       }
       ```
   
 * The problem I have with this code is that the `else` part is not working.. if
   someone sets a different `pid` on `/?pid=123` then the last post I set up for
   editing still shows up unless I click on submit.
 * What can I do to set the form to only receive the form details of `pid` and not
   stay there once I change the `pid`?
 *  Plugin Author [Aurovrata Venet](https://wordpress.org/support/users/aurovrata/)
 * (@aurovrata)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/edit-post-14/#post-16247176)
 * > The problem I have with this code is that the else part is not working.. if
   > someone sets a different pid on /?pid=123 then the last post I set up for editing
   > still shows up unless I click on submit.
 * well is the `$pid` isn’t set then surely you want to load a black form, no? In
   which case simply force the form pre-filling query to return a null result.
 * > What can I do to set the form to only receive the form details of pid and not
   > stay there once I change the pid?
 * I am not sure I follow what you mean
 *  Thread Starter [athep](https://wordpress.org/support/users/athep/)
 * (@athep)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/edit-post-14/#post-16247993)
 * > well is the $pid isn’t set then surely you want to load a black form, no? In
   > which case simply force the form pre-filling query to return a null result.
 * Thank you, this worked well
 *  Plugin Author [Aurovrata Venet](https://wordpress.org/support/users/aurovrata/)
 * (@aurovrata)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/edit-post-14/#post-16263921)
 * oh good! Marking this thread as resolved then

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Edit post’ is closed to new replies.

 * ![](https://ps.w.org/post-my-contact-form-7/assets/icon-256x256.png?rev=1985682)
 * [Post My CF7 Form](https://wordpress.org/plugins/post-my-contact-form-7/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/post-my-contact-form-7/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/post-my-contact-form-7/)
 * [Active Topics](https://wordpress.org/support/plugin/post-my-contact-form-7/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/post-my-contact-form-7/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/post-my-contact-form-7/reviews/)

 * 9 replies
 * 2 participants
 * Last reply from: [Aurovrata Venet](https://wordpress.org/support/users/aurovrata/)
 * Last activity: [3 years, 6 months ago](https://wordpress.org/support/topic/edit-post-14/#post-16263921)
 * Status: resolved