Change Post Categories After Date/Time

In preparation for the impending bad weather this coming Monday, I'm adding something to a non-profit radio station's website using Gravity Forms so that local schools, churches, etc can put in their delay/closing information.

Once this information is automatically published, I want it to change category from "Closings" to "Expired" (or something like that).

I've tried several plugins but since I'm using Gravity Forms to create the post, the "Post" function never fires in WordPress, so none of the plugins will automatically change or expire the post - nor will they set whatever they need so when a cron job runs they should perform.

So, I've played with a lot of PHP code trying to get the category to change. I have a hidden Custom Field that denotes when the post should change/expire, but every bit of code I've tried so far gives me errors and actually takes the site down.

Anyone have a code snippet in their bag of tricks that might work for this? I've got it posting automatically, so I can just manually do this for Monday, but it would be nice if I could go ahead and get it going automatically.

I also have their site automatically posting Nixel Alerts using the Postie plugin, but it also does not fire the normal "Post" function so those will not automatically expire/change. If I can figure one of these out, then I can kill two birds with one stone.

Thanks for any suggestions that anyone has.

  • James Dunn
    • The Crimson Coder

    Thanks for the suggestion Ari.

    The scheduled content plugin will not work (just as post expirator, content scheduler, and a half dozen other plugins will not work) - mainly because when the post is made using Gravity Forms, WordPress doesn't handle the Post action the same as if you clicked the "Publish" button in the WordPress Add New Post screen. It's the same issue when you use Postie to publish a post from outside of WordPress. The post is just published and the normal WordPress events never actually fire. This also keeps our Facebook plugin (the one here in WPMUDev) from publishing to Facebook, but that's another issue I'll tackle later.

    When the person submits their closing/cancellation announcement, they have the option to submit an expiration date for the announcement. If they do not submit a date of their choosing, then the Gravity Form is set to make that date correspond to the current date. That is the custom field I'm trying to use to actually act on the post and change it's category. For legal reasons, I can't just trash the post. They have to be kept on file for two years per FCC regulations. That's why I really want to change the category rather than simply change them back to draft. If the station is ever audited, they may need to produce a report of submissions. Plus, each day, they will need to be able to produce a report of submissions that went to air and the website and attach it to their log sheets for the day.

    I don't use the default WordPress posts functionality because that would require us to set up a user account for every school, every church, every event organizer, and every business that may need to submit inclement weather announcements. Using Gravity Forms, I've got a "code" field that requires them to put an authorization code in. If the code matches, their submission is immediately published (bypassing the standard WordPress "publish" function) and their announcement also goes immediately to air.

    But, if they put in the incorrect code or no code at all, then it will put it in a "Pending Review" status. I wrote a little code snippet in the functions.php file that handles this since it's not native to Gravity Forms either. When the reviewer looks at the post and finally publishes the post this way, he can either use content scheduler to schedule the expiration or many of the post expirator plugins work. But, I'm trying to automate as much of the process as possible.

    I've been tinkering with several code ideas for many hours on Saturday and I just can't seem to make it work. Some depended upon a CRON job, but I had no luck getting them to work either. I guess I'll keep hammering away at it over the next few weeks. Maybe I'll come up with it.

  • aristath
    • Recruit

    It sounds to me that you might simply have to do some custom coding to manually trigger the WordPress publishing action once a post is made using Gravity forms...
    Have you tried posting that on their forums? They are more familiar with their own plugin so they'll be able to help you achieve what you need a lot faster than us...


  • James Dunn
    • The Crimson Coder

    Been to Gravity Forms - got nowhere. They basically said it was a custom situation and beyond the scope of help. I was hoping that as I posted on about a half dozen groups that someone would say, "Oh hey, try this plugin or this script." and it would work. I figured it would be a custom coding situation. LOL Just really hate to sit down and custom code it if there's something available. But, guess I'll be coding this in the near future.

    Thanks Ari.

    James Dunn
    Athens, GA USA

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.