Change Post Status With a Button

Support MB Frontend Submission Change Post Status With a ButtonResolved

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #36865
    John RoodJohn Rood
    Participant

    Hi, wondering what options there are for a user to change a status of a post on the frontend using Frontend Submit. We are using Oxygen to display CPTs in a repeater. What we'd ultimately want is a way for a user to change a post to a custom status called 'accepted' which we already have set up. Is there a way to use one of the helper functions to accomplish that with just a simple button click, or do we have to actually have a field that does this, similar to this answer.

    I understand that getting the ID might be tricky, but I think I can handle that part. I am just looking for some direction on what to do once I have the correct post ID.

    #36870
    Long NguyenLong Nguyen
    Moderator

    Hi John,

    It can be done with a simple button click to save/change the post status but you will need more custom code to do that, not with just the helper function and form hooks.
    If you are not familiar with coding, you can create a service request here https://metabox.io/contact/, our development team will help you with an extra fee.

    #37211
    John RoodJohn Rood
    Participant

    We were able to accomplish this another way, thank you for your help!

    #37239
    YasmineYasmine
    Participant

    Hi John,

    What was your workaround? Did you manage to do with a button (rather than a switch) ?

    #37521
    Rebecca RobertsonRebecca Robertson
    Participant

    Hello John,
    Like Yasmine, I would also like to know how you accomplished this.

    #37522
    John RoodJohn Rood
    Participant

    So we ended up adapting the idea Long gave us in Gravity Forms rather than Meta Box, as we needed to use notifications to notify users when this happened. Basically, we set up a gravity form that was just the submit button and a hidden field. In the hidden field, we used Gravity Forms' Dynamic Population feature to pull in the post ID. Then we used the gform_after_submission hook to update the post's status on submit, using the ID as the method of getting the post.

    This is just a surface level explanation, as our use case is actually a lot more complicated than this, so I can't just post the code.

    #37523
    John RoodJohn Rood
    Participant

    Here is a stripped-down example of what I did, it is untested, but it should work just the same.

    https://pastebin.com/BivDXZg5

    This details how you would do the after_submission hook. The dynamic population feature is the first step, but how you implement that will depend on your project. All that matters is you need to get that ID in the hidden field before anything will work.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.