Change Post Status With a Button
Support › MB Frontend Submission › Change Post Status With a ButtonResolved
- This topic has 6 replies, 4 voices, and was last updated 3 years, 2 months ago by
John Rood.
-
AuthorPosts
-
July 8, 2022 at 2:06 AM #36865
John Rood
ParticipantHi, 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.
July 8, 2022 at 12:51 PM #36870Long Nguyen
ModeratorHi 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.July 26, 2022 at 9:46 PM #37211John Rood
ParticipantWe were able to accomplish this another way, thank you for your help!
July 28, 2022 at 5:09 AM #37239Yasmine
ParticipantHi John,
What was your workaround? Did you manage to do with a button (rather than a switch) ?
August 16, 2022 at 9:21 PM #37521Rebecca Robertson
ParticipantHello John,
Like Yasmine, I would also like to know how you accomplished this.August 16, 2022 at 10:00 PM #37522John Rood
ParticipantSo 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_submissionhook 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.
August 16, 2022 at 10:07 PM #37523John Rood
ParticipantHere is a stripped-down example of what I did, it is untested, but it should work just the same.
This details how you would do the
after_submissionhook. 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. -
AuthorPosts
- You must be logged in to reply to this topic.