Skip Navigation

[Resolved] Creating and displaying custom post type edit history

This support ticket is created 6 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

Tagged: 

This topic contains 5 replies, has 2 voices.

Last updated by Minesh 6 years, 2 months ago.

Assisted by: Minesh.

Author
Posts
#1110757

Hi, I'm building a ticketing system using custom post type for the ticket, custom field to hold the ticket's status, CRED for displaying the submission form, and native WordPress comment for responses (with additional plugin to enable attachment in comment section).

At the moment there is no frontend form for editing submitted tickets. But occasionally administrators can manually edit ticket's title and/or description from the backend for clarity.

Now I need to display ticket's history on its single page template that includes the time, the user, and the action given to the ticket. The actions would be:
- submission, when the ticket was submitted
- edit, when manually edited
- status change, when changed, for example, from New to Progress, or from Progress to Closed
- optionally, comments, when submitted

The desired output would be similar to this:
[user 1] created this ticket at [time]
[user 2] edited this ticket at [time]
[user 3] set this ticket to 'Progress' at [time]
[user 3] submitted a comment at [time]
[user 1] submitted a comment at [time]
[user 1] set this ticket to 'Closed' at [time]

What's the best way to do it? Do I use hooks in combination with repeatable field groups that adds an entry every time the ticket is saved? Do I need another post type?

#1111314

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

I would say you may create a new post type "Ticket Action Log" and add few fields to it like time, status (New, Progress, Close) and a field to store the user id.

And later on use views to display your ticket history.

#1111316

Thank you for your response.

Can you be more detail especially on how new entries on this "Ticket Action Log" custom post get inserted?

#1111317

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - obviously, you need to use PHP API for this.

You need to create a new post each time you perform any action with all the field values.

So, you can use "save_post" action.
=> https://toolset.com/documentation/customizing-sites-using-php/updating-types-fields-using-php/

#1112019

Would you mind telling me why you recommend a post type as opposed to repeatable field groups within the existing post type?

What are the pros and cons fo each one?

#1112045

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Would you mind telling me why you recommend a post type as opposed to repeatable field groups within the existing post type?
=> Well - when you use post type it will give you more control when you want to display related content and also it will allow you to filter the results whereas when you use repeatable fields group there is the limitation.