Custom Fields
Re-Envisioned
Support MB Custom Table Commenting System - Custom Table Approach

  • Creator
    Topic
  • #29138
    Nicholas Cox
    Participant

    Hi

    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

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
    Replies
  • #29148
    Long Nguyen
    Moderator

    Hi 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/

    #29172
    Nicholas Cox
    Participant

    Hi

    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

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.