Commenting System - Custom Table Approach
Support › MB Custom Table › Commenting System - Custom Table Approach
- This topic has 2 replies, 2 voices, and was last updated 3 years, 10 months ago by
Nicholas Cox.
-
AuthorPosts
-
June 26, 2021 at 5:53 PM #29138
Nicholas Cox
ParticipantHi
I have come across this guide PHP MySQL Commenting System and I am trying to think of the best approach to re-building this into a custom table using Meta Box. The front end commenting system in this guide just creates threaded comments when viewing a specific post id and allows you to reply to comments. then stores the post id to retrieve them later and orders them by date. I do not want to use the default WordPress commenting system as custom fields is not supported in the front end.
Ideas:
-
1. My first idea was to create a 'custom table' and then use the rest of the logic in the guide and just replace PDO logic with WP Query etc and this should work fine. But my issue with this approach is that on the front end of the site I wont be able to use Meta Box fields? so defeats the object of using Meta Box. Also I would have to perform additional queries to retrieve the data from the custom table and output this as a separate script.
-
2. Another idea is to create a custom table like before but use Meta Box 'group fields', but then the fields will be stored as a 'serialized array' which is not a bad thing? but I'm just wondering will this be bad on a performance level with unserializing upon each page visit?
The positives is that I can just call the group field via the meta box helper function (as the comments have already been stored against the post id the user is currently viewing). The serialized array will be outputted and I guess I will then just save the form once the user has filled it in. My only concern is that if there is more than one user commenting at the same time then the data may get missed?.Any pointers of alternative approaches would be greatly appreciated.
Also a side note on this topic is that if WordPresss core supported custom comment types (like how post types work) then I guess it would possibly help with developing a solution with metabox https://github.com/sc0ttkclark/wp-custom-comment-types
Thanks
Nick
June 27, 2021 at 1:39 PM #29148Long Nguyen
ModeratorHi Nicholas,
Instead of doing a lot of works to create a comment system, add the custom fields for comments on the frontend. I think you can follow this topic to add some fields to comments on the frontend and save them to the
wp_commentmeta
table of WordPress.
https://wordpress.org/support/topic/add-a-new-field-to-comment-form/June 28, 2021 at 6:07 PM #29172Nicholas Cox
ParticipantHi
Thanks for this but as I am going to store 3 additional fields into the 'wp_commentmeta' table this will not work for me, as my metadata will be stored in multiple rows instead of single rows. I am going to have alot of comments per post I can see this database size bloating pretty quick. I have a feeling there is not going to be a clean solution for my problem other than spending the time to build a bespoke commenting system so I can optimise front end performance.
Thanks
Nick
-
AuthorPosts
- You must be logged in to reply to this topic.