Site icon Hip-Hop Website Design and Development

How to create review point system for CPTs (many-to-many relationship)

I am working on a WordPress project where I have movies, books and games as custom post types. Any logged in user can add stars(review points) to each of the CPTs.

My way of implementing this was create new CPT called review. When user clicks on star to add review points to certaint CPT it creates new post with type review which in itself has meta fields review_post_id(which holds ID of post(movie,book,game) user is adding review points to) and review_score(which holds score user has selected (1-5 points)).

To show avg review score I just loop through all reviews which have review_post_id of ceratin post and then sum them and divide by number of reviews. Since reviews are custom post types I can show each user his own review score.

Now, mainly I am asking this question to see if this is correct way to do this(since same principal can be used for many other use cases) and also because of more experinced developer told me that I should have not created new CPT (review) and should use post_meta table of WordPress.

But I don’t think this is possible to overcome using wp_posts_meta, since this is many-to-many relationship and users and posts are one-to-many relationship.

Any suggestion is appreciated.

Thanks in advance and happy new year!

EDIT: I found that custom comment type can be used which links user to certain post, this could be the solution as this relationship is clearly many-to-many and I could store review_score(points) in comments meta table. Just want to hear your opinion on what is the best way to do this.