• I am currently using a chat plugin for my website, but I want to make user chat more core functionality. My thought is to make a custom post type chat_post or something similar and implement a way for users to type up a message/post, and have it appear in the chat. This would be similar to google groups.

    My question is on implementation. If I do use a custom post type there would be thousands of posts each year that would add up and potentially slow down database queries? Would there be a better alternative implementation?

    What I want is more custom than most plugins so I can design it myself, I just want it to be efficient a few years down the road so I don’t have to go back.

    If I need to clarify anything let me know, this might be a little unorthodox.

Viewing 3 replies - 1 through 3 (of 3 total)
  • I have recently been involved with a project were 10’s of thousands of records get imported as custom post types on a daily basis, and this does not slow the database down significantly so I think you would be OK.

    Saying that there are pro’s and cons to doing it this way. Using a custom post type you can use the WP_Query object to query your custom postype for example. However you lose some ability to index tables and normalise the data.

    If you are worried about clogging up the database you could archive the posts with your custom post type after a period (maybe rolling 12 monthly), which would keep the tables cleaner.

    Another alternative is to use your own tables. You would not be able to use WP_Query but would probably have to use the functions available on the global $wpdb variable (see https://codex.www.ads-software.com/Class_Reference/wpdb), abd write your own sql. You would have more control over the table(s) however, and could normalise and index them to make sure you application was performant.

    At the end of the day each implementation is valid and I think it simply comes down to how you want to implement it. It’s doesn’t quite answer your question, but I hope it might help in some way.

    Thread Starter jpurdy647

    (@jpurdy647)

    This is exactly the answer I was looking for, thanks!

    My next question is would I be able to modify the custom post type admin page, where edit.php lets you edit the posts? I did some looking on google and it looks like you can only create an additional settings page. If that is the only way to go I could make a redirect from the post admin page(edit.php?post-type=my_new_post_type) to my own admin page for managing the chat.

    If you register a custom post type you will automatically get a page for your custom post type. See https://codex.www.ads-software.com/Post_Types and the section on Custom Post Type Screens

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Best way to implement a chat system’ is closed to new replies.