PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Gravity Forms + Content Scheduler (auto post expiration)

  1. jojobo
    Member

    Hi,

    I'm really loving the plugin and am nearly finished with the last little bit of functionality for my site. I'm trying to get Gravity Forms to play nice with the Content Scheduler plugin. Essentially, I have a form that allows users to create a post from the front-end and requires them to choose a start date and an end date for their promotion.

    I've managed to use the forums to successfully get the start date => scheduled post (thanks guys!)

    Now I need their post to be tagged with the "expired" tag once the date they enter for their end date has passed. The plugin is capable of that but I want to enter the data from the front end.

    The plugin requires a radio button on/off which writes to "_cs-enable-schedule" so I need to autopopulate that to true first of all.

    Once that's done I need to push the entered date to "_cs-expire-date" and add append a time to the end of it (23:00:00).

    I found this post in the forums but he didn't fully describe how he got it working. Any suggestions or pointers would be extremely appreciated.

    Here's the form in question: http://www.specficdaily.com/limited-time-freebie-submission/

    Posted 11 years ago on Wednesday December 26, 2012 | Permalink
  2. Sounds like _cs-expire-date is a custom field? If so, add a custom field (a Post field) to your form, and make it a radio button or checkbox, or even just a text field, and make the visibility admin only. That will write the value of 'true' (or is it "1"?) to the custom field. Does that take care of that portion? You should manually set a schedule on a post, then take a look at the format of the values stored in the postmeta table for that post, to be sure you are creating values in the proper format.

    Then it sounds like this is an additional custom field you need stored "_cs-expire-date" - with the value of 23:00:00 (or is that variable?)?

    You can use the gform_after_submission hook to add a custom field value to the post which was just created. http://www.gravityhelp.com/documentation/page/Gform_after_submission Again, be sure to check the format that the custom fields are written in by the plugin, and mimic that in your code.

    Posted 11 years ago on Wednesday December 26, 2012 | Permalink
  3. jojobo
    Member

    Hi Chris, thanks for taking the time to answer.

    _cs-expire-shcedule is the custom field that the plugin is creating/using and the value is "Enable".

    _cs-expire-date is the other custom field the plugin uses, and it requires a date and time formatted like this: yyyy/mm/dd HH:00:00

    So I'd like to take *my* custom date field $date-expiry and then add HH:00:00 to the end of it before passing the result to _cs-expire-date.

    Posted 11 years ago on Wednesday December 26, 2012 | Permalink
  4. Is _cs-expire-shcedule working correctly at this point?

    Posted 11 years ago on Wednesday December 26, 2012 | Permalink
  5. jojobo
    Member

    Hm, it's not. I'm rethinking my approach a bit and would rather avoid the plugin all together. Here's my goal:

    Custom date field "wpcf-post_expire". Once that date has passed then add the post_tag "expired" to the post. That's it.

    Posted 11 years ago on Wednesday December 26, 2012 | Permalink
  6. OK. What sort of help do you need with that?

    Posted 11 years ago on Wednesday December 26, 2012 | Permalink
  7. jojobo
    Member

    Well, I have a question. I'm using ACF to create my fields. All of the other fields store the entered data in the appropriate MetaBox, but wpcf-post_expire doesn't (but it does show listed under the "custom fields" MetaBox. Is that due to it being a datepicker or is there something else going on here?

    Provided that doesn't mean something is screwy and it is in fact different because of being a date picker, then I need to figure out the last part which has nothing to do with your plugin so I can try to go bug someone else.

    Posted 11 years ago on Wednesday December 26, 2012 | Permalink
  8. I don't have any experience with ACF. As long as the data is being stored properly in a custom field, I would not worry about the admin interface and meta box. That is just an interface to making the custom fields easier to use. Does the data exist in the database in the correct format, with the correct meta key name?

    Posted 11 years ago on Wednesday December 26, 2012 | Permalink
  9. jojobo
    Member

    Hm. Sorta?

    Ok, when I check the post in the database it lists this:

    wpfc-post_expiration_date 12/23/2012

    which is correct and what I entered on the form front-end, so yeah, that part is working.

    Posted 11 years ago on Thursday December 27, 2012 | Permalink
  10. jojobo
    Member

    Ok, just a small update. I can get the "_cs-expire-schedule" radio button enabled by default without a problem.

    _cs-expire-date is being a pain. No method of dynamically populating it works (even if I reuse something I know works elsewhere on the form) but merge tags and default values will show up.

    I'm starting to think it's something in the coding of the plugin blocking the entry because unless I enter a default value or merge tag then it doesn't show up for the post meta of the database at all.

    Posted 11 years ago on Thursday December 27, 2012 | Permalink
  11. I doubt that it is anything in the plugin blocking your entry. You just need to get the data in exactly the right format, with the exact meta key name.

    Posted 11 years ago on Thursday December 27, 2012 | Permalink
  12. jojobo
    Member

    Thanks Chris, you were (of course) right. I wasn't entering the time properly at the end of it. I managed it with using a modified version of the code you guys provided here http://www.gravityhelp.com/documentation/page/Gform_post_data

    Posted 11 years ago on Sunday December 30, 2012 | Permalink
  13. Thank you for that update.

    Posted 11 years ago on Sunday December 30, 2012 | Permalink

This topic has been resolved and has been closed to new replies.