Using usermeta vs new user field
-
I’m writing a plugin that uses the YouTube javascript API to display a long YouTube video and allow the user to store their progress so they can pick up where they left off. I haven’t found an existing plugin that provides this functionality, so I’m trying it myself. I have some experience writing simple WordPress functions and plugins, but this is the most complex I’ve attemtped.
So far, I’ve worked out everything I need to make the YouTube player work and provide running count of the playhead’s position. I know how to make a shortcode to embed a video with this functionality into a page and enqueue the js needed.
I’m looking for some advice on the next step, which is how best to store the video progress value in the database so the logged in user can later restore the player to that point and continue, and let the administrator see how far along they are, as well. This is for training purposes.
What’s the best way to store that value? There are three ways I can think of:
1. Have my plugin create its own table for storing that data. But I would have to build a relationship between that table and the user ID.
2. Add a field to the user table, again during the plugin activation, so that each user would have that data stored in their row, which might make writing and retrieving the data easier.
3. Use the usermeta table to store the data. I’m assuming that WordPress already has the tools to create the user to usermeta relationship pretty easily.I imagine that the data to be stored would be a JSON array, as there would be an indeterminate number of Youtube video ID’s and the number of seconds recorded for each user. Something like this:
videoID1 => seconds; videoID2 => seconds, etc.So can anyone suggest the best course of action? Or offer an alternative suggestion? Or just point me in the direction of a good tutorial that demonstrates how to accomplish this sort of thing?
Thanks
- The topic ‘Using usermeta vs new user field’ is closed to new replies.