Support

Account

Home Forums Front-end Issues Post from draft to published

Solving

Post from draft to published

  • I’ve created a front end form that creates a new custom post type, it saves this as a draft. I now want to allow the user to either update this draft version or, once they are happy with it, publish it. Am I able to do this with any existing ACF functionality?

    Thanks,
    Helen

  • Hi @hhumphrey

    You sure can.

    Firstly, to edit the draft, you will need to know the ID of the draft / post. You can find this via the user’s ID (all posts are connected to a user) or perhaps via a GET parameter sent back from the acf_form redirect or perhaps via another completely different method.

    I would then create a link to the current page but add a GET param called ?update={$draft_id}. On the page template (which holds the form), you can look for the existence of this GET param. If it exists, modify the acf_form args to use that post_id! This will allow you to edit an existing post / draft.

    To then publish it, you have 2 options:
    1. Add a custom field radio button which you can use a toggle switch (draft / publish). ACF has a hook for the update_value filter which you can use to look at this radio button value and then update the $post based on it (update the post status to publish)

    2. Create a custom button to a custom link (perhaps another GET param) which then your template can use to just update the post status

    Good luck

    Cheers
    E

  • Hey Elliot,
    I am sorry is this issue still open? can you please explain in details? sorry I am not able to get the draft and publish part to work 🙁

    I have managed to create a frontend form template using this tutorial,

    https://itsmereal.com/frontend-post-submission-edit-advanced-custom-fields/

    currently this works likes this:-
    When author click submit, it creates a posts and sets it as a draft status and the admin have to set the post to publish then author can edit the post in the front end. Which is ok for the published posts.

    What I want is just a bit more added to this functionality. I want when the author submits the posts, he should be able to edit the posts in draft status and also be able to publish it or make it a draft again.

    Can you please explain how can I achieve this? I see that you have mentioned of GET param ?update={$draft_id} on page template(where author submits the posts) I am not sure how to do this,

    For the 2nd part changing the posts status from draft to publish or vice versa I have created a radio button to toggle between ‘draft’ and ‘publish’ but again i am not able to place them in right place to make it work 🙁

    Your help would be highly appreciated 🙂

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Post from draft to published’ is closed to new replies.