In this tutorial you will learn how to make your posts expire automatically after a pre-set duration.

In Part 1 and 2, we built a form that allowed users to add ads directly from the front-end. Now, we will set an automatic expiration duration for all posts submitted through that form.

Enabling Automatic Expiration of Posts
Enabling Automatic Expiration of Posts

We set our posts to be automatically trashed after a two-week duration (according to the post publish date).

We will set Toolset CRED to check the posts daily. If an Ad post has the Post Expiration Date set and the post has been in the site for two weeks already, it will be trashed automatically.

Enabling Automatic Expiration of Posts

You set the automatic expiration of posts on the CRED post form level. However, automatic expiration of posts is disabled by default.

To see the Automatic Expiration section in your CRED post forms, first you need to enable it in Toolset Settings.

Enabling Automatic Expiration of Posts
Enabling Automatic Expiration of Posts

In your CRED Training Site:

1. Go to Toolset -> Settings.
2. Click the Forms tab.
3. Locate the Other section.
4. Check the Enable Automatic Expiration of Post options for CRED Post Forms option.
5. In the dropdown that appears below choose Once Daily.

Now, when the Automatic Post Expiration feature for CRED Post Forms is enabled, you can set the expiration time in your CRED form for adding new Ads.

Using Automatic Expiration in CRED forms

You set the automatic expiration of posts on the CRED post form level
You set the automatic expiration of posts on the CRED post form level

1. Go to Toolset -> Post Forms
2. Open the “Add new Ad” CRED form you created in Part 1
3. In the Settings section you will see a new section called “Expiration Date” (see the screenshot)
4. Check “Set expiration date for post created or edited by this form”
5. Set the expiration time for 2 Weeks.
6. From the dropdown that follows choose Trash

Hereafter, each new Ad added through this form will have its Expiry Date set automatically for two weeks from the post publish date.

After a duration of two week the ads will be automatically trashed.

Testing the Post Expiration Date

Testing the Post Expiration Date
Testing the Post Expiration Date

1. On the site’s front-end, go to the “Place your free ad” page.
2. Add a new ad through the form (the form you created in Part 1).
3. Open the add in your WordPress back-end.
4. On the right sidebar you should see a new section entitled “Settings for Post Expiration Date”.
5. The Post Expiration Date is set to two weeks ahead from today’s date.

The post will be trashed automatically two weeks from now.


Toolset hint

Hint
If you would like to display the Post Expiration Date on single Ad pages, use the [cred-post-expiration] shortcode in your Single Ad Content Template.

You can also send email notifications based on the Post Expiration Date.

Visit the Automatic post expiration in CRED forms page for details.

Need help? Questions?

Go to the CRED Course Support page and leave your comment. Agnes, the author of the course will be happy to help you.

What’s next

In the next tutorial, you will learn how to you to create front-end forms for editing ads.

Part 5 – Building forms for content editing